You are not logged in.

#1 2008-03-16 20:02:09

FeatherMonkey
Member
Registered: 2007-02-26
Posts: 313

PHP htmlentities doesn't work.

Why does this not work I'm guess I'm missing something.

Using these examples I found.

$userInput = "I am going to hax0r your site, hahaha!
        <script type='text/javascript'>
        window.location = 'http://www.example.com/'
        </script>'";
        
$userInputEntities = htmlentities($userInput);

echo $userInputEntities;
$str = "A 'quote' is <b>bold</b>";
echo htmlentities($str);

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

Now running on cli with php.

        <script type='text/javascript'>
        window.location = 'http://www.example.com/'
        </script>'A 'quote' is <b>bold</b><a href='test'>Test</a>

Works fine yet through apache its not working, could some one point me in the direction to look, to solving why.

Offline

#2 2008-03-22 21:23:11

Eliteforce
Member
Registered: 2006-03-26
Posts: 56

Re: PHP htmlentities doesn't work.

eh i didn't really understand what your problem is, but the $new = .. echo $new should output this:

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

edit: dmmit the forum replaces the html entity of the single quote, instead of the single quotes you should actually get '&#039'

Last edited by Eliteforce (2008-03-22 21:25:35)

Offline

Board footer

Powered by FluxBB