#42864 [Opn->Bgs]: strip_tags() doesn't work as expected with PHP tags
| From: | vrana@php.net | Date: | Wed, 21 Nov 2007 15:08:41 +0000 |
| Subject: | #42864 [Opn->Bgs]: strip_tags() doesn't work as expected with PHP tags | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-234@lists.php.net to get a copy of this message | ||
ID: 42864
Updated by: vrana@php.net
Reported By: kraghuba at in dot ibm dot com
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: windows XP,linux
PHP Version: 5.2.4
New Comment:
strip_tags() works exactly as documented: "This function tries to
return a string with all HTML and PHP tags stripped".
Previous Comments:
------------------------------------------------------------------------
[2007-10-08 11:01:45] rquadling@php.net
What is missing though is a way to preserve the PHP "tag".
Just as HTML comments are always removed, PHP code will be also.
Both the HTML comments and PHP "tags" fail to match the usual formats
of HTML tags ...
<tag></tag> or <tag />
So
<!-- xxxx -->
<?php xxxx ?>
are not capable of being described for allowable_tags.
------------------------------------------------------------------------
[2007-10-06 00:00:42] jani@php.net
According to the sources this is expected behaviour.
And it's pretty simple, <?php $foo=1; ?> is just another tag. So it's
stripped as would something like <img src="foo.gif" /> be sripped..
------------------------------------------------------------------------
[2007-10-05 10:39:53] kraghuba at in dot ibm dot com
This behavior is found on php6 as well.
------------------------------------------------------------------------
[2007-10-05 10:37:18] kraghuba at in dot ibm dot com
Description:
------------
when a string with PHP tag(<?php ?>) is given as input to strip_tags()
function, it strips off the entire given string including the tags.
Whereas, the function should only strip the tags and not the text within
the PHP block.
As per the documentation, this seems to be non-documented behavior, is
this expected?
Reproduce code:
---------------
<?php
var_dump(strip_tags("<?php echo \"hello\" ?>"));
?>
Expected result:
----------------
string(12) "echo "hello""
Actual result:
--------------
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42864&edit=1