Jump to content

can you strip php tags without stripping html?


blufish

Recommended Posts

'/(?:<\?|<\?php)(?:.*|\t*|\r*|\n*|\r\n*|\a*|\e*|\f*|\v*)*\?>/'

This is a regex that will catch anything between <? and ?> or <?php and ?>

$pattern = '/(?:<\?|<\?php)(?:.*|\t*|\r*|\n*|\r\n*|\a*|\e*|\f*|\v*)*\?>/';
$text = preg_replace($pattern, '', $sourceText);

Assumming $sourceText = the text file read in.

This is remove any an all PHP from the file and will store it in the $text variable.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.