[chora] patch for htmlspaces

Cynic cynic@mail.cz
Wed, 23 May 2001 18:37:37 +0200


since when is empty( 0 ) false?

D:\work\projekty\roaming>php -v
4.0.6-dev

D:\work\projekty\roaming>php -q
<? $x = 0 ; var_dump( empty( $x ) ) ; ?>
^Z
bool(true)

D:\work\projekty\roaming>

At 17:56 23.5. 2001 +0200, Mathieu Arnold wrote:
>here is a patch, to allow $text to be 0 (zero) because if $text = 0,
>empty($text) is false....
>
>
>Index: lib/base.php
>===================================================================
>RCS file: /home/cvs/cvs/dup/horde/chora/lib/base.php,v
>retrieving revision 1.42
>diff -u -r1.42 base.php
>--- lib/base.php        2001/04/26 00:20:37     1.42
>+++ lib/base.php        2001/05/23 15:54:58
>@@ -242,12 +242,12 @@
>    * @return The HTML-compliant converted text.  It always returns at
>least
>    *         a non-breakable space, if the return would otherwise be
>empty.
>    */
>-function htmlspaces($text='') {
>+function htmlspaces($text='  ') {
>      $text = htmlentities($text);
>      $text = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $text);
>      $text = str_replace('  ', '&nbsp; ', $text);
>      $text = str_replace('  ', ' &nbsp;', $text);
>-    return empty($text)?'&nbsp;':$text;
>+    return $text;
>  }
>
>  /**
>
>
>
>--
>Mathieu Arnold
>
>--
>Chora mailing list: http://horde.org/chora/
>Frequently Asked Questions: http://horde.org/faq/
>To unsubscribe, mail: chora-unsubscribe@lists.horde.org



cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
     - Book of Installation chapt 3 sec 7