note 57544 deleted from function.htmlspecialchars by cmb

From: Date: Sun, 27 Oct 2019 09:14:22 +0000
Subject: note 57544 deleted from function.htmlspecialchars by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212841@lists.php.net to get a copy of this message
Note Submitter: mikiwoz at yahoo dot co dot uk ---- I am not sure, maybe I'm missing something, but I have found something interesting: I've been working on a project, where I had to use htmlspecialchars (for opbvious reasons). I olso needed to de-code the encoded string. What I have done was almost a copy and paste from php.net: $trans=get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES); $trans=array_flip($trans); $string=strtr($encoded, $trans); (it looked a bit different in my code, but the idea is clear) I couldn't get the apostrophe sign de-coded, and I needed it for the <A> tags. After an hour or so of debuging, I decided do print_r($trans). What I got was: ... [&#39;] => ' ... BUT the apostrophe was encoded to $#039; -> note the zero. I don't suppose it's a bug, but it definetely IS a potential pitfall, watch out for this one.

« previous php.notes (#212841) next »