Re: htmlentities()

From: Date: Sat, 17 Nov 2007 16:24:20 +0000
Subject: Re: htmlentities()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-264749@lists.php.net to get a copy of this message
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@elmit.com> 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


« previous php.general (#264749) next »