这段代码有什么问题:
<?php eval(" $start = microtime(true)*1000; echo 'hello'; $end=microtime(true)*1000; $time = $end-$start; $time = round($time,4); echo '<br />Time taken: '.$time.'ms<br />'; "); ?>
它只是一行代码(不要问为什么),但为了可读性,我再说一遍
<?php
eval(" $start = microtime(true)*1000;
echo 'hello';
$end=microtime(true)*1000;
$time = $end-$start;
$time = round($time,4);
echo '<br />Time taken: '.$time.'ms<br />';
");
?>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Parse error: syntax error, unexpected '=' in ...\test2.php(1) : eval()'d code on line 1
当使用双引号时,你必须转义每个美元符号,没有它,php将尝试将范围内的变量解析为最终字符串.
由于您可能没有$start定义变量,因此将其视为空字符串,并且您的代码以'='开头.
| 归档时间: |
|
| 查看次数: |
13312 次 |
| 最近记录: |