Re: htmlentities()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is doing that ;)

If you look at the source, you will see the expected output.



On Nov 17, 2007, at 4:41 AM, Ronald Wiplinger <ronald@xxxxxxxxx> wrote:

I tried to understand htmlentities by putting this code into a test.php:

<?php
if(!$page) {
?>
<H3>Test of evil input</H3>

<form method="post" action="<?php echo $PHP_SELF?>">

<INPUT type="text" name="field1" size="100" maxlength="100">
<INPUT type="hidden" name="page" value="1">
<INPUT type="submit" name="submit" value="Check it!">
</form>

<?php
}
else
{
echo "field1=$field1<br>";
$field2=htmlentities($field1,ENT_QUOTES,UTF-8);
echo "field2=$field2<p>";
echo htmlentities($field1,ENT_QUOTES,UTF-8);

echo "<p>";
$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);
echo "<br>";
// Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);

}
?>



The output on the screen is:

field1=*Greater input and lower input*
field2=<b>Greater input and lower input</b>

<b>Greater input and lower input</b>

A 'quote' is <b>bold</b>
A 'quote' is <b>bold</b>


I expected that it would give me in the second line:
field2=&lt;b&gt;Greater input and lower input&lt;/b&gt;

and the lower two lines I expected as:

A 'quote' is &lt;b&gt;bold&lt;/b&gt;
A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;


What do I miss understand here?

bye

Ronald

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux