我在Windows平台上,我在app/webroot/fontomjs上有可执行的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 2>&1', $s, $o);
echo $response;
echo "<pre>";
print_r($s);
echo "</pre>";
echo "<pre>";
print_r($o);
echo "</pre>";
我得到
Array
(
)
1
编辑2:
这很好:
echo exec("whoami");
编辑3:这毫无作用:
$response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js 2>&1', $s, $o);
我也面临同样的问题。。问题是phantomjs需要所有人都有完整的路径。这是我想出的解决方案:
$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);