Rumah  >  Artikel  >  php教程  >  解决执行PHP文件 eval()’d code问题

解决执行PHP文件 eval()’d code问题

WBOY
WBOYasal
2016-06-06 20:11:199579semak imbas

当使用PHP eval 函数执行 一个PHP文件是报错: Parse error: syntax error, unexpected in eval.php(5) : eval()d code on line 1 查了一下PHP文档,发现eval是执行 或 ? ? 中包含的代码。 解决方法 $file = file_get_contents(modules.php); $arr = eval(?.

当使用PHP eval 函数执行 一个PHP文件是报错:

Parse error: syntax error, unexpected ‘

查了一下PHP文档,发现eval是执行 或 ?> 中包含的代码。

解决方法

$file = file_get_contents(‘modules.php’);
$arr = eval(‘?>’.$file.’

注意:

还有其他形式,如果PHP环境 short_open_tag = On ,还可以使用:

$arr =eval(‘?>’.$file.’’);

或者

eval(‘?>’.$file);

理解 eval 函数就是解析 php 中的代码就行,php文件的末尾可以不带 ?>。

(...)
Read the rest of 解决执行PHP文件 eval()’d code问题 (1 words)


© lixiphp for LixiPHP, 2013. | Permalink | No comment | Add to del.icio.us
Post tags: eval, PHP

Feed enhanced by Better Feed from Ozh

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn