Re: Re: [PHP-WEBMASTER] php with htmlspecialchars function

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

 



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@xxxxxxx> wrote:

> On Fri, Mar 11, 2011 at 13:07, Lisa Nguyen <lisa.nguyen@xxxxxxxxxxxx>
> 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/
>
> --
> 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