尝试打印命令的实时输出时,在 system() 命令之后未执行 PHP 代码



我有这段代码来运行命令并打印实时输出,问题是system()命令之后的代码没有被执行。如何解决此问题?

function disable_ob() {
// Turn off output buffering
ini_set('output_buffering', 'off');
// Turn off PHP output compression
ini_set('zlib.output_compression', false);
// Implicitly flush the buffer(s)
ini_set('implicit_flush', true);
ob_implicit_flush(true);
// Clear, and turn off output buffering
while (ob_get_level() > 0) {
// Get the curent level
$level = ob_get_level();
// End the buffering
ob_end_clean();
// If the current level has not changed, abort
if (ob_get_level() == $level) break;
}
// Disable apache output buffering/compression
if (function_exists('apache_setenv')) {
apache_setenv('no-gzip', '1');
apache_setenv('dont-vary', '1');
}
}
function build() {
$location = "build/" . date("Y-m-d-h-i-sa");
echo "Build started! Your build location is " . $location;
$url =  "http://{$_SERVER['HTTP_HOST']}";
$escaped_url = htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' );       
echo "nIf you don´t get redirected after build go to $escaped_url/" . $location . "/smefs-Indigo-Remastered-master/Release/smef.pw.dlln";
echo "...n";
mkdir($location, 0777, true);
dircpy("","buildfiles/smefs-Indigo-Remastered-master",$location . "/smefs-Indigo-Remastered-master",true);
copy("buildfiles/buildscript.bat",$location . "/buildscript.bat");
copy("buildfiles/JunkCode.exe",$location . "/JunkCode.exe");
#shell_exec('call ' . $location . "/buildscript.bat");
system('call ' . $location . "/buildscript.bat");
# THIS CODE NOT EXECUTED
echo "nn# BUILD COMPLETED #";
echo "If you aren´t redirected please go to this link to download build: " . $location . "/smefs-Indigo-Remastered-master/Release/smef.pw.dll";
header('Location: '. $location . "/smefs-Indigo-Remastered-master/Release/smef.pw.dll");
}

固定!问题是,我把超时设置为 30 秒。添加ini_set('max_execution_time', 3600);后一切正常!

最新更新