Re: [PHP4BETA] propose for bool -> string conversion:
| From: | Sascha Schumann | Date: | Fri, 02 Jul 1999 14:13:59 +0000 |
| Subject: | Re: [PHP4BETA] propose for bool -> string conversion: | ||
| References: | 1 2 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-1818@lists.php.net to get a copy of this message | ||
> Because you can't just do if($x) since both "" and 0 are treated as false.
> That doesn't mean the function isn't working. The function is defined to
> return a number from 0-n on a match and "" (false) on a failure.
Yes, I know. That is what I pointed out earlier...
> It's not the most consistent thing in the world, but having it
> return 1, for example, would also suck because then you would
> have to fudge the return value when you wanted to use it
> directly as a string index. ie.
>
> $string[strpos($a,"a")];
That's a broken script. It's as silly as
fpassthru(fread($somefile, "r"));
because they both depend on the success of the inner function
which cannot be guaranteed always. If the user does some kind of
check, so that the inner function is guaranteed to succeed, we can
also return -1 or whatever.
--
Regards,
Sascha Schumann
Consultant