我需要做这样的事情:
header("Content-Type: text/plain");
echo <<<EOT
<?php echo 'arbitrary code using ' . $variables . ' and such.';
echo 'finished';
?>
EOT;
Run Code Online (Sandbox Code Playgroud)
问题是,PHP仍然将内联PHP解释为代码并尝试执行它.我想只看到窗口中打印的代码.
使用Nowdoc,注意周围的引号'EOT':
echo <<<'EOT'
<?php echo 'arbitrary code using ' . $variables . ' and such.';
echo 'finished';
?>
EOT;
Run Code Online (Sandbox Code Playgroud)
或者使用单引号字符串,显然在字符串中转义单引号:
echo '
<?php echo \'arbitrary code using \' . $variables . \' and such.\';
echo \'finished\';
?>';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
70 次 |
| 最近记录: |