Re: PHP newbie question
| From: | Cynic | Date: | Wed, 10 Jan 2001 18:41:15 +0000 |
| Subject: | Re: PHP newbie question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33728@lists.php.net to get a copy of this message | ||
since when is false equal to one? in PHP, false is represented
by string(0) "", and true by 1. so, you really want
<?php if (! $a) print !$a; ?>
At 19:33 10.1. 2001, Neil Zanella wrote the following:
--------------------------------------------------------------
>On Wed, 10 Jan 2001, Toby Butzon wrote:
>
>> : <?php if (! $a) print "Hello, World!"; // script 2 ?>
>>
>> $a evaluates to false, the ! reverses it, and it prints "Hello, World!"
>
>What is bothering me is the following: if variables that are not assigned
>a value were to evaluate to false then since false is the same as the
>number 1 the following PHP script should print the number 1 but instead
>prints nothing:
>
><?php if (! $a) print $a; ?>
>
>How is this behavior justified?
>I could not find anything on this in the PHP manual.
>
>Thanks,
>
>-- Neil
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz