有时候我们require_once()几个文件,这些文件因为前边有空格或是其它原因有输出,就会后边就会出现一系列的问题,包括 session。通过php生成图片等。
这时候找不出输出在哪。可以在这个文件头加上
最开始加上
ob_start();
require_once();
require_once();
require_once();
ob_end_clean();
这样子可以把require_once包含的文件中的不明输出去掉
PS:对于AJAX XML有用
=========================
PHP 清除已经echo的内容
<div>passing </div>
<?PHP
echo 'here...';
// 代码 清除第一个echo的输出内容的“代码”
echo 'there...';
exit;
?>
有没有办法 只输出第二个echo的内容‘there...’(前提是两个echo代码都不能删除,之前还有必须得输出的内容(顶部的div),而只想得到第二个 echo输出的内容‘there...’)
<?PHP
ob_start();
echo 'here...';
ob_clean();
ob_end_flush();
echo 'there...';
exit;
?>
这样写是可以实现的.就是输出时缓冲一下, 再把缓存删了
发表评论