php method to clear unknown output: first open the corresponding PHP file; then add the statement "ob_start();require_once();ob_end_clean();" to the file header.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to clear unknown output in php?
php clear unknown output
Sometimes we require_once() several files, and these files have output because of spaces in front or other reasons, A series of problems will appear later, including session. Generate pictures, etc. through php.
Can't find where the output is at this time. You can add
to the header of this file and
ob_start(); require_once(); require_once(); require_once(); ob_end_clean();
at the beginning. This way you can remove the unknown output in the file included in require_once
PS : Useful for AJAX XML
PHP Clear the echoed content
<div>passing </div> <?PHP echo 'here...'; // 代码 清除第一个echo的输出内容的“代码” echo 'there...'; exit; ?>
Is there any The method is to only output the content of the second echo 'there...' (the premise is that neither echo code can be deleted, and there is content that must be output before (the div at the top), but you only want to get the content output by the second echo 'there...')
<?PHP ob_start(); echo 'here...'; ob_clean(); ob_end_flush(); echo 'there...'; exit; ?>
Writing like this is achievable. Just buffer it when outputting, and then delete the cache
[Recommended learning: PHP video tutorial】
The above is the detailed content of How to clear unknown output in php. For more information, please follow other related articles on the PHP Chinese website!