Re: [PHP4BETA] propose for bool -> string conversion:

From: Date: Sat, 03 Jul 1999 03:18:02 +0000
Subject: Re: [PHP4BETA] propose for bool -> string conversion:
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-1851@lists.php.net to get a copy of this message
"Thies C. Arntzen" wrote: > > On Fri, 2 Jul 1999 bourbon@netvision.net.il wrote: > > > On Fri, 2 Jul 1999, Thies C. Arntzen wrote: > > > > > On Fri, 2 Jul 1999 bourbon@netvision.net.il wrote: > > > > > > > On Fri, 2 Jul 1999, Thies C. Arntzen wrote: > > > > > > > > > > > > > > this patch will get us the "good old php3 behaviour" back: > > > > > > > > > > true -> "1" > > > > > false -> "" (instead of "0") > > > > > > > > Why does it matter? > > > > > > 'cause otherwise it'll break a lot of php-code that's around;-) > > > > > > eg: the "good ole "if (strlen(strpos..." won't work otherwise > > > > > > <? > > > echo strlen(strpos("hallo","h"))."\n"; > > > echo strlen(strpos("hallo","w"))."\n"; > > > ?> > > > > > > php3: > > > Content-type: text/html > > > > > > 1 > > > 0 > > > > > > php4: > > > Content-Type: text/html > > > > > > 1 > > > 1 > > > > > > > > > i don't think people will like this! > > > > Well, I don't like that code either since it's very wrong (they should not > > rely on false being "", EVER; It's false, and that means it can be > > "", > > "0" or 0; That was true for PHP 3.0, in PHP 4.0 there's even a special > > boolean type). > > zeev - > agreed, but this is a semantic change! we all have to be aware of that. > > i believe that people won't be happy with this as this is also a > "hard-one" to track down in their php code. i would propose to make it a > c.ini setting (like plus_overloading is). > > as far as i can see we're talking about 2 places in libzend > (zend_make_printable_zval, convert_to_string) - i would vote for the .ini > setting! > The above discussed strpos() problem is just another example of the wrong concept how to handle inbound signaling in php. This sticks to several array traversion functions, too, and has been discussed since the very early alpha/beta phase of PHP3 by Kris and me on the mailing lists at that time. Unless you change the semantics of the language you will run into that sort of problem again and again. I see this as a chance to correct somthing that has been wrong for a long time. Because if you are honest the generic/natural/canonical semantics of the following are simply: 0: a natural number indicating the the amount of none. "": an empty string "0": a string containing the character '0' false: a boolean constant indicating that something is logicaly false true: a boolean constant indicating that something is logicaly true (I am not talking of NIL or a bottom symbol for now... ) Well, this is only my mind, and it doesnt count of course: Sometimes the right thing to do _is_ painfull and means a lot of work. But it _will_ make php better. Maybe a config switch can be used to force php4 into the dirty php3 mode or to let php4 shine from tidy semantics :-) ? Boris

« previous php.version4 (#1851) next »