Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1688

Re: How to "quote code" in PHP?

From "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Newsgroups comp.lang.php
Subject Re: How to "quote code" in PHP?
Date 2011-05-20 09:34 +0200
Organization http://alvaro.es/
Message-ID <ir55ie$ha3$1@dont-email.me> (permalink)
References <ir45oo$mik$1@dont-email.me>

Show all headers | View raw


El 20/05/2011 0:31, Mentalguy2k8 escribió/wrote:
> I'm trying to put together a little page with a form, so that users can
> "translate" any URL into the correct format for posting on a forum.
>
> For instance, they want to share a link and type in "www.google.com"
> (without quotes) and the form turns it into "<a
> href="www.google.com"></a>" (without the beginning and end quotes) and
> displays that as text, so that they can copy/paste it into the forum
> post box. It will also include an image-posting version so that it adds
> the "<img src" etc to an image URL.
>
> How do I "quote" the result so that it displays as plain text rather
> than a mess? All I'm getting is a mess of blue code.

The function to escape HTML is htmlspecialchars():

http://php.net/htmlspecialchars

Make sure you use it every time you print arbitrary plain text, not only 
in this case.


-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to "quote code" in PHP? "Mentalguy2k8" <Mentalguy2k8@gmail.com> - 2011-05-19 23:31 +0100
  Re: How to "quote code" in PHP? Jeff North <jnorthau@yahoo.com.au> - 2011-05-20 10:47 +1000
  Re: How to "quote code" in PHP? Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-19 21:47 -0400
  Re: How to "quote code" in PHP? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-05-20 09:34 +0200
    Re: How to "quote code" in PHP? "Mentalguy2k8" <Mentalguy2k8@gmail.com> - 2011-05-20 09:44 +0100
      Re: How to "quote code" in PHP? Michael Fesser <netizen@gmx.de> - 2011-05-20 10:54 +0200
        Re: How to "quote code" in PHP? Jeff North <jnorthau@yahoo.com.au> - 2011-05-20 20:21 +1000
          Re: How to "quote code" in PHP? "Mentalguy2k8" <Mentalguy2k8@gmail.com> - 2011-05-20 17:21 +0100

csiph-web