使用preg_replace将'<?php *?>'转换为空(删除所有PHP代码) [英] Using preg_replace to convert '<?php*?>' to nothing (removing all PHP code)

查看:69
本文介绍了使用preg_replace将'<?php *?>'转换为空(删除所有PHP代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我试图使用preg_replace来读取所有PHP代码的出现

读取(fread())之后的内容PHP文件。我使用的代码

是:


$ html = preg_replace("<?php *?>","", $ html);


不幸的是它无法正常工作并发出以下错误:

警告:preg_replace():在
C:/ apache / ...

有人可以试一试,看看他们得到了什么。我该如何才能上班?


干杯


Burnsy

Hi,

I am trying to use preg_replace to take out all occurances of PHP code
after reading (fread()) the contents of a PHP file. The code I am using
is:

$html = preg_replace("<?php*?>", "", $html);

Unfortuntely it is not working and giving the following error:
Warning: preg_replace(): Nothing to repeat for offset 0 in
C:/apache/...
Can someone please try this out and see what they get. How can I get
this to work?

Cheers

Burnsy

推荐答案

html = preg_replace("<?php *?>","",
html = preg_replace("<?php*?>", "",


html);


不幸的是它无法工作并发出以下错误:

警告:preg_replace():在

C:/ apache / ...

有人可以试一试,看看他们得到了什么。我该如何才能上班?


干杯


Burnsy

html);

Unfortuntely it is not working and giving the following error:
Warning: preg_replace(): Nothing to repeat for offset 0 in
C:/apache/...
Can someone please try this out and see what they get. How can I get
this to work?

Cheers

Burnsy


2005年9月2日13:57:49 -0700, bi **** **@yahoo.co.uk 写道:
On 2 Sep 2005 13:57:49 -0700, bi******@yahoo.co.uk wrote:
我试图使用preg_replace读取所有出现的PHP代码
(fread() )PHP文件的内容。我使用的代码是:

I am trying to use preg_replace to take out all occurances of PHP code
after reading (fread()) the contents of a PHP file. The code I am using
is:


这篇关于使用preg_replace将'&lt;?php *?&gt;'转换为空(删除所有PHP代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆