|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-07-19 17:48 UTC] yml at dtlink dot com
[2002-07-19 19:14 UTC] sniper@php.net
[2002-07-19 19:14 UTC] rasmus@php.net
[2002-07-19 19:27 UTC] yml at dtlink dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 18:00:01 2025 UTC |
Stock install of php 4.2.1 with the default php.ini file. The following script demonstrates that str_replace() munches double quotes when it shouldn't. <? $source_vars[1] = '${TEXT}'; $replace_vars[1] = '<font size="1"><a href="javascript:self.close();">Close Window</a></font>'; $source_string = '<a href="${TEXT}" >'; $expandedStr = str_replace( @$source_vars, @$replace_vars, @$source_string ); print( "<h1>EXPANDED_STR is: '$expandedStr'" ); ?> You will notice that the output of this script is: <h1>EXPANDED_STR is: '<a href="<font size="1><a href="javascript:self.close();">Close Window</a></font>" >' Note the missing " at on the font tag size="1 ... If you remove the double quotes from source_string as in: $source_string = '<a href=${TEXT} >'; Then the output is correct as: <h1>EXPANDED_STR is: '<a href=<font size="1"><a href="javascript:self.close();">Close Window</a></font> >' well, aside from the fact that the href= needs the double quotes. Originally I thought this was restricted to array reference replacements but if you use the straight string form of str_replace the same behavior happen