lolalola
lolalola

Reputation: 3823

PHP: htmlspecialchars_decode with double quotes won't work

i have encoded text with html elements. In this text i have single quotes and double quotes.

By PHP manual htmlspecialchars_decode($string, ENT_QUOTES) should decode all quotes. Double quotes have "034" code, but this now work.

My code:

$new = htmlspecialchars_decode('<a href="test'>Test</a>', ENT_QUOTES);

var_dump($new);

Result: string '<a href=&#034;test'>Test</a>' (length=28)

Why i get "&#034;" ? It should be double quotes

Upvotes: 2

Views: 852

Answers (1)

rjdown
rjdown

Reputation: 9227

htmlspecialchars_decode seems to work a little differently on older versions. Try html_entity_decode instead:

$new = html_entity_decode('&lt;a href=&#034;test&#039;&gt;Test&lt;/a&gt;', ENT_QUOTES);

Upvotes: 3

Related Questions