Re: html_entities_decode, but ignoring embedding php tags
| From: | Richard Lynch | Date: | Thu, 24 Feb 2005 16:50:28 +0000 |
| Subject: | Re: html_entities_decode, but ignoring embedding php tags | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-209375@lists.php.net to get a copy of this message | ||
Tim Burgan wrote:
> I have a string:
> $str = '<p>This is a paragraph<p><?php echo
> \'hello\';
> ?>';
>
> Which I convert using:
> html_entity_decode(stripslashes($str));
>
> Which result in:
> <p>This is a paragraph</p><?php echo 'hello'; ?>
>
>
> But.. I was the PHP tags to STAY ENCODED like:
> <p>This is a paragraph</p><?php echo 'hello'; ?>
$str = '<p>This is a paragraph<p><?php echo
\'hello\';?>';
//No need for stripslashes with the above input...
$decode = html_entity_decode($str);
$record = str_replace('<?php', '<?php', $decode);
$recode = str_replace('?>', '?>', $recode);
This won't work well if somebody does:
$str = htmlentities('This is the <?php echo "<?php"?> "start"
tag');
Depending on why you need this, and what you are doing, there are other
things you could do, but I don't want to try to guess what you need this
for...
--
Like Music?
http://l-i-e.com/artists.htm