RE: [PHP] Inconsistent String Definition (string position starts at zero)?
| From: | Adam Warner | Date: | Sun, 26 Nov 2000 04:28:25 +0000 |
| Subject: | RE: [PHP] Inconsistent String Definition (string position starts at zero)? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27216@lists.php.net to get a copy of this message | ||
Thanks Ignacio,
!==false worked! I thought the extra = was a typo. I really appreciated the
very useful and prompt response. I've still got to try and understand why
that worked. The manual states:
One last thing worth mentioning is the truth value of expressions. In many
events, mainly in conditional
execution and loops, you're not interested in the specific value of the
expression, but only care about
whether it means TRUE or FALSE (PHP doesn't have a dedicated boolean type).
The truth value of
expressions in PHP is calculated in a similar way to perl. Any numeric
non-zero numeric value is TRUE,
zero is FALSE. Be sure to note that negative values are non-zero and are
thus considered TRUE! The
empty string and the string "0" are FALSE; all other strings are TRUE. With
non-scalar values (arrays
and objects) - if the value contains no elements it's considered FALSE,
otherwise it's considered TRUE.
--
OK so there does appear to be a manual omission. But what's the significance
of the extra symbol because !=false doesn't work?
I'll give it a go:
!=false evaluates whether the expression is not zero.
!==false evaluates whether the function returns false.
So why doesn't ===true evaluate whether the function returns not false?
Thanks again,
Adam
-----Original Message-----
From: Ignacio Vazquez-Abrams [mailto:ignacio@openservices.net]
Sent: Sunday, 26 November 2000 2:53 p.m.
To: Adam Warner
Cc: php-general@lists.php.net
Subject: Re: [PHP] Inconsistent String Definition (string position starts at
zero)?
Try:
if (strpos($t,"text")!==false) ...
The PHP manual has an omission about the Boolean type and its two possible
values (true and false), but that's not quite the problem you're having
here.
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>