note 118874 deleted from function.htmlspecialchars by cmb

From: Date: Sat, 20 Feb 2016 17:32:30 +0000
Subject: note 118874 deleted from function.htmlspecialchars by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-204997@lists.php.net to get a copy of this message
Note Submitter: David Spector ---- At least two years ago an important PHP application I wrote (an order processing system) stopped working in certain cases, with text being erased, requiring difficult manual intervention. As described in other comments here, the problem was that code like "$Str=htmlspecialchars($Str)" had stopped working reliably. I've found that Dave's solution presented here did not work for me in every case. I finally solved this problem by replacing all such htmlspecialchars calls with the following function, which should work for every character encoding: function SafeStr($Str) // For showing user input on page in HTML { return str_replace(array('&','<','>','"','\''), array('&amp;','&lt;','&gt;','&quot;','&apos;'), $Str); } // SafeStr

« previous php.notes (#204997) next »