PDA

View Full Version : Anyone have a html stripper in php?


joor
12-11-2002, 11:40 PM
I am looking for a regular expressions function that will strip the html when I pass a variable through it. I have one for asp, but I am just making my move over to php and google has not turned one up. Just hoping that someone may have one laying around. TIA

DrkFusion
12-12-2002, 07:24 PM
Strip?

Xenon
12-12-2002, 07:25 PM
hmm, are you talking bout the htmlspecialchars function?

Logician
12-19-2002, 11:16 AM
$string = strip_tags($string);

Dean C
12-19-2002, 11:41 AM
I had a look at what "strip_tags" does and i don't quite understand..

If you assign a variable which is html does it strip the html from the variable?

- miSt

Dean C
12-19-2002, 11:41 AM
So would this work?


$mist = <b>Mist</b>
$mist = strip_tags($mist);

nsr81
12-19-2002, 11:55 AM
No, but this will :D


$mist = "<b>Mist</b>";
$mist = strip_tags($mist);

Dean C
12-19-2002, 11:59 AM
ahhh but why the quotes?

I was once told quotes aren't needed when assigning a variable?

- miSt

Velocd
12-19-2002, 12:52 PM
Quotes are needed in variables that contain strings which include spaces in them, characters such as the exclamation mark that could conflict with code syntax, or HTML, javascript, etc.

Will work:

$string = "hello world";

or

$string = helloworld;

or

$string = 12342342345345;


Wont work:

$string = hello world;

or

$string = 32423 234234;

or

$string = <b>helloworld</b>;

or

$string = helloworld!!!;

Dean C
12-19-2002, 01:34 PM
ahhh thanks for explaining it to me :)!

- miSt