PHP 4.0 Bug #8998 Updated: htmlspecialchars() DONT convert a string/array ONCE

From: Date: Tue, 30 Jan 2001 15:39:24 +0000
Subject: PHP 4.0 Bug #8998 Updated: htmlspecialchars() DONT convert a string/array ONCE
Groups: php.dev 
Request: Send a blank email to php-dev+get-45416@lists.php.net to get a copy of this message
ID: 8998 Updated by: zak Reported By: lopez@pepe-lopez.com Status: Open Bug Type: Strings related Assigned To: Comments: The code in your example does not work due to problems with your string quoting. $foo = "<a href="foo">..</a>"; // This is not a valid string // PHP generates a parse error after the 2nd quote Try this code snippet and let me know if it works: <pre> <?php $foo = '<a href="foo">..</a>'."\n"; $foo = htmlspecialchars($foo); print $foo; // Should output &lt;a href=&quot;foo&quot;&gt;..&lt;/a&gt; $foo = '<a href="foo">..</a>'."\n"; print $foo; // Should output <a href="foo">..</a> ?> Previous Comments: --------------------------------------------------------------------------- [2001-01-30 07:12:39] lopez@pepe-lopez.com ReEdit... Please note: $foo = "<a href="foo">..</a>"; $foo = htmlspecialchars($foo); //now $foo is "& lt;a href="foo"& gt;..& lt;/a& gt;" $foo = "<a href="foo">..</a>"; //$foo is & lt;a href="foo"& gt;..& lt;/a& gt; //although $foo is filled with a new value, $foo converts the string! --------------------------------------------------------------------------- [2001-01-30 07:10:04] lopez@pepe-lopez.com Please note: $foo = "<a href="foo">..</a>"; $foo = htmlspecialchars($foo); //now $foo is "&lt;a href="foo"&gt..&lt;/a&gt" $foo = "<a href="foo">..</a>"; //$foo is &lt;a href="foo"&gt..&lt;/a&gt; //although $foo is filled with a new value, $foo converts the string! //sorry, my english is too poor to explain more --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8998

« previous php.dev (#45416) next »