Accéder au contenu.
Menu Sympa

technique - Re: [TECH] PHP et HTML

Objet : Liste pour les discussions techniques (liste à inscription publique)

Archives de la liste

Re: [TECH] PHP et HTML


Chronologique Discussions 
  • From: Patrice Pillot <patrice.pillot AT teletopie.net>
  • To: technique AT april.org
  • Subject: Re: [TECH] PHP et HTML
  • Date: Thu, 27 Sep 2007 20:01:19 +0200

David Lapetina a écrit :
> Bonjour,
> quelqu'un sait-il comment en php purger une chaine de tous les tags HTML
> présent ?

RTFM

strip_tags

(PHP 3 >= 3.0.8, PHP 4, PHP 5)
strip_tags -- Strip HTML and PHP tags from a string
Description
string strip_tags ( string str [, string allowable_tags] )

This function tries to return a string with all HTML and PHP tags
stripped from a given str. It uses the same tag stripping state machine
as the fgetss() function.

You can use the optional second parameter to specify tags which should
not be stripped.

et aussi, en moins violent :

htmlspecialchars

(PHP 3, PHP 4, PHP 5)
htmlspecialchars -- Convert special characters to HTML entities
Description
string htmlspecialchars ( string string [, int quote_style [, string
charset]] )

Certain characters have special significance in HTML, and should be
represented by HTML entities if they are to preserve their meanings.
This function returns a string with some of these conversions made; the
translations made are those most useful for everyday web programming. If
you require all HTML character entities to be translated, use
htmlentities() instead.

This function is useful in preventing user-supplied text from containing
HTML markup, such as in a message board or guest book application. The
optional second argument, quote_style, tells the function what to do
with single and double quote characters. The default mode, ENT_COMPAT,
is the backwards compatible mode which only translates the double-quote
character and leaves the single-quote untranslated. If ENT_QUOTES is
set, both single and double quotes are translated and if ENT_NOQUOTES is
set neither single nor double quotes are translated.

The translations performed are:

*

'&' (ampersand) becomes '&amp;'
*

'"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set.
*

''' (single quote) becomes '&#039;' only when ENT_QUOTES is set.
*

'<' (less than) becomes '&lt;'
*

'>' (greater than) becomes '&gt;'





Archives gérées par MHonArc 2.6.16.

Haut de le page