Re: php with htmlspecialchars function

From: Date: Fri, 11 Mar 2011 18:21:15 +0000
Subject: Re: php with htmlspecialchars function
References: 1  Groups: php.general php.webmaster 
Request: Send a blank email to php-webmaster+get-10619@lists.php.net to get a copy of this message
On Fri, Mar 11, 2011 at 13:07, Lisa Nguyen <lisa.nguyen@jpl.nasa.gov> wrote: > Hi > > I use one of your example to test the htmlspecialchars : > > <?php > $new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); > echo $new; // &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt; > ?> > > On my browse, it display like below > <a href='test'>Test</a> > > Instead: > Test > > Please help me how display on browse only "Test", not like view source. First, this isn't a support channel. Please view http://php.net/support for a brief list of available support methods. The list you want is PHP General (CC'd on this email, and you can subscribe at http://php.net/mailinglists ). Second, you're using htmlspecialchars(), which is converting the < and > to &lt; and &gt; respectively, which will cause the browser to display it as if it was source (though viewing the source of that would show you the entities). Instead, check out strip_tags(), which is likely what you want: http://php.net/strip_tags -- </Daniel P. Brown> Network Infrastructure Manager http://www.php.net/

« previous php.webmaster (#10619) next »