|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[1999-07-21 04:32 UTC] webmaster at softgallery dot com
I found two bugs in the new parser.
First str_replace does not behave correctly :
$Content = str_replace("{$Toreplace}",$Val,$Content);
with $Val a string, does not remove the {} (template)
Then ereg_replace :
$Content = ereg_replace("\{$ARemplacer\}",$Val,$Content);
with $Val an int put some garbage characters in the output instead
of the value of $Val
I hope this helps.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 03:00:01 2025 UTC |
a simple one for ereg_replace : echo ereg_replace("\{FOO\}",1,"testtest{FOO}testtest"); does not output testtest1testtest, but testtest.garbagechar.testtest but echo ereg_replace("\{FOO\}","1","testtest{FOO}testtest"); works normally. As for str_replace I did not find a test case. This is a quite complex script and I can't provide it to the mailing list . Here is a bit of the code : for ($j=0;$j<count($Templates["ParseVars"][$Name]);$j++) { $ToReplace = strtoupper($Templates["ParseVars"][$Name][$j]); $Val = $Vals[strtoupper($ToReplace)]; $Content = str_replace("{$ToReplace}",$Val,$Content); } In PHP for example $Content ouputs : BEFORE "NOM_CAT" -> "Web Tools" {CAT_LIEN}{NOM_CAT} AFTER {CAT_LIEN}Web Tools With PHP4 : BEFORE "NOM_CAT" -> "Web Tools" {CAT_LIEN}{NOM_CAT} AFTER {CAT_LIEN}{Web Tools} I tried to put some strings directly in the varaibles but the function behaved normally, so perhaps the problem is more complex. I can provide the code to a PHP developper directly, but it's not commented and all variables names are french, so it won't be easy to read. Feel free to ask anyway.