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

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

WBOY
WBOYOriginal
2016-06-06 20:11:199580Durchsuche

当使用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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn