Re: [PHP4BETA] propose for bool -> string conversion:
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: [PHP4BETA] propose for bool -> string conversion: | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-1806@lists.php.net to get a copy of this message | ||
> strpos has never worked in the case of the needle at the first
> (index 0) position.
Sure it has. It has always worked and I use it all the time. eg.
$string = "abc";
echo "[".strpos($string,"a")."]\n";
echo "[".strpos($string,"z")."]\n";
This prints out:
[0]
[]
And as such correctly identifies the "a" in the first position in the
first case and in the second case it tells you that the needle wasn't
found.
> You also cannot use strstr everywhere - if
> the needle is at the end of the haystack, it returns an empty
> string which happens to be equal to false.
Again, this is not true. eg.
$string = "abc";
echo "[".strstr($string,"c")."]\n";
echo "[".strstr($string,"z")."]\n";
This prints:
[c]
[]
Which means it saw the needle at the end quite nicely.
-Rasmus