Re: [PHP4BETA] propose for bool -> string conversion:
| From: | Thies C. Arntzen | Date: | Fri, 02 Jul 1999 14:45:15 +0000 |
| Subject: | Re: [PHP4BETA] propose for bool -> string conversion: | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-1827@lists.php.net to get a copy of this message | ||
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:
> > >
> > > > diff -w -u -r1.14 zend_operators.c
> > > > --- zend_operators.c 1999/06/26 11:48:22 1.14
> > > > +++ zend_operators.c 1999/07/02 12:08:46
> > > > @@ -287,8 +287,13 @@
> > > > case IS_STRING:
> > > > break;
> > > > case IS_BOOL:
> > > > - op->value.str.val =
> > > > (op->value.lval?estrndup("1",1):estrndup("0",1));
> > > > + if (op->value.lval) {
> > > > + op->value.str.val =
> > > > estrndup("1",1);
> > > > op->value.str.len = 1;
> > > > + } else {
> > > > + op->value.str.val = empty_string;
> > > > + op->value.str.len = 0;
> > > > + }
> > > > break;
> > > > case IS_LONG:
> > > > lval = op->value.lval;
> > > >
> > > > 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!
again, i think we should be as compatible as possible to php3.
tc
>
>
> Zeev
>
>
Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!"
Digital Collections Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93 20097 Hamburg / Germany