Re: str_replace() broken in 4.2.1 (Apache 1.3.26/Linux 2.2)
| From: | Richard Lynch | Date: | Sat, 20 Jul 2002 07:10:17 +0000 |
| Subject: | Re: str_replace() broken in 4.2.1 (Apache 1.3.26/Linux 2.2) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108641@lists.php.net to get a copy of this message | ||
>In PHP 4.2.1 (stock php.ini) under Linux (RedHat 6.1) using Apache
>1.3.26 the following code:
>
>$source = 'TEXT';
>
>$replace = '<tag attribute=\"1\"><tag
>attribute=\"blah\">';
Why in the world are you doing \" in there?
You either want \\" or just ", but not \"
But $replace is not being filled with a valid string -- or at least probably
not the string you think it is...
>$template = '<attribute="TEXT">';
>$expandedStr = str_replace( $source, $replace, $template );
>
>print( "<h1>Result is: '$expandedStr'</h1>" );
>
>Yields the incorrect result:
>
><h1>Result is: '<attribute="<tag attribute="1><tag
>attribute="blah">">'</h1>
>
>Note the missing ".
>
>However, if the <> are removed from $template then the result becomes:
>
><h1>Result is: 'attribute="<tag attribute=\"1\"><tag
>attribute=\"blah\">"'</h1>
>
>which in this context is correct.
>
>I've filed a bug report but wanted to ask if anyone else has seen this?
--
Like Music? http://l-i-e.com/artists.htm