在 php 中,有没有办法清除/删除所有先前回显或打印的项目?
例如:
<?php
echo 'a';
print 'b';
// some statement that removes all printed/echoed items
echo 'c';
// the final output should be equal to 'c', not 'abc'
?>
我的脚本使用 include 函数。包含的文件不应回显任何内容。以防万一有人(例如黑客)尝试,我需要一种方法来删除。
<?php
ob_start();
echo 'a';
print 'b';
// some statement that removes all printed/echoed items
ob_end_clean();
echo 'c';
// the final output is equal to 'c', not 'abc'
?>
输出缓冲功能 http://php.net/manual/en/ref.outcontrol.php
输出缓冲函数在黑客中也很有用,可以强制只打印返回字符串的函数,即。
<?php
ob_start();
var_dump($myVar);
$data = ob_get_clean();
// do whatever with $data
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)