You are here: Re: [PHP] html_entities_decode, but ignoring embedding php tags « PHP « IT news, forums, messages
Re: [PHP] html_entities_decode, but ignoring embedding php tags

Posted by Richard Lynch on 02/24/05 18:50

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>&lt;?php echo 'hello'; ?&gt;

$str = '&lt;p&gt;This is a paragraph&lt;p&gt;&lt;?php echo \'hello\';?&gt;';
//No need for stripslashes with the above input...
$decode = html_entity_decode($str);
$record = str_replace('<?php', '&lt;?php', $decode);
$recode = str_replace('?>', '?&gt;', $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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация