Issues with strip_tags(fixed)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Issues with strip_tags(fixed)

Post by Bigun »

I was under the assumption that strip_tags would remove all tags except for the ones that are specified safe.

I setup the following strip_tags command:

Code: Select all

$inputaboutme=strip_tags($inputaboutme, '<a><b><i><u>');
$inputaboutme is a textarea.

When I put the following text into the textarea:

Code: Select all

<html>
<body background="http://www.cybergrunge.com/bg3.jpg">
<b>Testing 123</b>
</body>
</html>
It outputs this after processing:

Code: Select all

<html>
<body background=\"http://www.cybergrunge.com/bg3.jpg\">
<b>Testing 123</b>
</body>
</html>
Only thing I saw change was the quotes commented out for echo'ing.

Help?

*EDIT*

Corrected typo..
Last edited by Bigun on Wed Jul 05, 2006 8:02 am, edited 3 times in total.
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

Forgive me.... it is a textarea...
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

<?php
$str = '
<html>
<body background="http://www.cybergrunge.com/bg3.jpg">
<b>Testing 123</b>
</body>
</html>
';
var_dump(phpversion());
var_dump(strip_tags($str, '<a><b><i><u>'));
?>
output:

Code: Select all

:!php q3.php
string(5) "4.4.0"
string(24) "


<b>Testing 123</b>


"
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

Code: Select all

PHP Version 4.4.2
The only thing I can think of is my typo.

Would passing the value striaght from a textarea effect anything?
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

Nevermind...

Posted the code in the wrong area..... my dumb*** fault...
Post Reply