PHP Check If require_once() Content Is Empty

喜夏-厌秋 提交于 2019-12-05 22:34:58

You can capture the output using ob_start, ob_get_contents and ob_end_clean like this:

ob_start();
require_once('script.php');
$output = ob_get_contents();
ob_end_clean();
ob_start();
require_once 'your_file.php';
$output = ob_get_flush(); // ob_get_clean() if you want to suppress the output

if(empty($output)) {
    echo 'Nothing interesting here!';
}

Do not worry if the require_once is executed on not. Try to identify if the variables/functions of require_once files are working or not by using the debug function like this:-

var_dump($Your_Variable_Name_from_require_Once_file);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!