ereg_replace update
| From: | George Hartz | Date: | Tue, 17 Aug 1999 21:27:08 +0000 |
| Subject: | ereg_replace update | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-3525@lists.php.net to get a copy of this message | ||
Okay, my bad. Pulled a new CVS tree, the ereg_replace coredump has been
fixed.
But -- the problem with the use of an integer as a string still happens
in PHP4.
I don't want to file a bug on it before I know it actually IS a bug.
Actually it seems to work differently from PHP3 now too...
Basically, as I said in my other e-mail, this is the sample code:
<?php
$number = 1000;
$string = "/something/%s/";
$string = ereg_replace("\%s", $number, $string);
print "<H1>$string</H1>\n";
?>
In PHP3, I get /something/1000/ as the output unless $number is less
than 256, then I seem to get /something/*/ where * is the character
represented by the ascii value of $number. In PHP4, I get an "è" (sorry
if that doesn't come through in an e-mail). If I cast it using (string)
$number in the ereg_replace call, it works as you'd expect.
Is this a bug, or a feature? It seems like a *very* non-standard thing
to do in a non-typed (or at least not strongly-typed) language to
convert and number to a character when doing a non-specific string
conversion, rather than converting it to a string representation of the
number.
- George
--
email:dotorg@bangsplat.org;url:www.bangsplat.org;uin:153182;aim:tgd98
GCS/GP/GS/GFA d- s+: a- C++++$ UL++++$ P+++$ L+++$ E- W++>$ N+@ !o
K+++ w--- !O M-@ V PS+ PE Y+ PGP t-(+) 5- X++ R-(--) tv+ b+++ DI++ D++
G+ e* h r y++