Php exec()phantomjs不';t执行,没有显示错误
我在Windows平台上,在app/webroot/phantomjs上有phantomjs可执行文件,在同一个文件夹中有一个js。 当我使用php时:Php exec()phantomjs不';t执行,没有显示错误,php,exec,phantomjs,Php,Exec,Phantomjs,我在Windows平台上,在app/webroot/phantomjs上有phantomjs可执行文件,在同一个文件夹中有一个js。 当我使用php时: $response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js'); 什么也没发生。以下是js的内容: console.log('Hello, world!'); phantom.exit(); 我使用绝对路径,因为这需要在线在网页上执行 编辑1
$response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js');
什么也没发生。以下是js的内容:
console.log('Hello, world!');
phantom.exit();
我使用绝对路径,因为这需要在线在网页上执行
编辑1:
使用时
$response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js 2>&1', $s, $o);
echo $response;
echo "<pre>";
print_r($s);
echo "</pre>";
echo "<pre>";
print_r($o);
echo "</pre>";
编辑2:
这很好:
$getout = exec('D:\\xampp\\htdocs\\phantomjsdir\\phantomjs.exe D:\\xampp\\htdocs\\rasterisejsdir\\rasterize.js http://localhost/pagetobecaptured/test D:\\xampp\\htdocs\\outputfiledir\\test2.jpg "1800px*840px"',$o,$e);
编辑3:
这没有任何作用:
我也面临同样的问题。。 问题是phantomjs需要所有人的完整路径。 以下是我提出的解决方案:
请启用错误报告并尝试将sterr管道化为stout:已启用错误报告,无结果。与2>&1相同,您应该检查
$this->webroot
是否只包含正向斜杠,并以一个斜杠结尾。检查完整路径是否正确(echo
it)。getweb脚本是否也需要特定路径?路径正确,并且getweb位于完全相同的文件夹中。
echo exec("whoami");
$response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js 2>&1', $s, $o);
$getout = exec('D:\\xampp\\htdocs\\phantomjsdir\\phantomjs.exe D:\\xampp\\htdocs\\rasterisejsdir\\rasterize.js http://localhost/pagetobecaptured/test D:\\xampp\\htdocs\\outputfiledir\\test2.jpg "1800px*840px"',$o,$e);