Re: Re: php with htmlspecialchars function
| From: | NetEmp | Date: | Fri, 11 Mar 2011 19:51:25 +0000 |
| Subject: | Re: Re: php with htmlspecialchars function | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311780@lists.php.net to get a copy of this message | ||
Well Lisa, that is exactly the way htmlspecialchars is supposed to work.
Here you could also display - Test - without using any function at all,
simply echo "<a href='test'>Test</a>"; and this should work well.
NetEmp
On Fri, Mar 11, 2011 at 11:51 PM, Daniel Brown <danbrown@php.net> wrote:
> 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; // <a href='test'>Test</a>
> > ?>
> >
> > 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 < and > 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/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>