Jump to content

[SOLVED] htmlspecialchars problem


LemonInflux

Recommended Posts

I'm using WAMP, XAMPP is set up (localhost). Say we use this example:

 

<?php
$new = htmlspecialchars("<a href='test'>Test</a>");
echo $new;
?>

 

for some reason, the code outputs:

 

<a href='test'>Test</a>

 

I looked on php.net, and tried their example; still didn't work. Has anyone had this problem? Anyone any ideas?

Link to comment
https://forums.phpfreaks.com/topic/76433-solved-htmlspecialchars-problem/
Share on other sites

Take a look at the source of the generated code. Your php script is generating the correct HTML character codes; your browser is rendering them as the correct character.

 

Edit: However, with your present code, nothing would happen anyway. To turn single quotes into &#039;, ENT_QUOTES must be set. See:

 

www.php.net/htmlspecialchars

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.