Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wkhtmltoimage和PHP调试_Php_Wkhtmltopdf - Fatal编程技术网

wkhtmltoimage和PHP调试

wkhtmltoimage和PHP调试,php,wkhtmltopdf,Php,Wkhtmltopdf,我试图用PHP来抓取一个屏幕。它不工作,但我不知道如何调试它。我联系了我的服务器管理员,他们说允许执行exec。以下是我的目录结构: -index.php -lib/ -screenshot.php -wkhtmltoimage/ -wkhtmltoimage-i386 -wkhtmltoimage-amd64 screenshot.php中的代码如下: function screenshot($url, $save_path, $zoom = 0.5, $widt

我试图用PHP来抓取一个屏幕。它不工作,但我不知道如何调试它。我联系了我的服务器管理员,他们说允许执行
exec
。以下是我的目录结构:

-index.php
-lib/
  -screenshot.php
  -wkhtmltoimage/
     -wkhtmltoimage-i386
     -wkhtmltoimage-amd64
screenshot.php
中的代码如下:

function screenshot($url, $save_path, $zoom = 0.5, $width = 500)
{
    $zoom = escapeshellarg($zoom);
    $width = escapeshellarg($width);
    $url = escapeshellarg($url);
    $save_path = escapeshellarg($shell_path);

    print_r(scandir("lib/wkhtmltoimage"));

    $output = array();

    echo exec("./lib/wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("lib/wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("./wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("./lib/wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("lib/wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("./wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);

    print_r($output);
    die();
}
index.php调用函数screenshot on url“http://www.nasa.gov/“

以下是我得到的输出:

Array
(
    [0] => .
    [1] => ..
    [2] => wkhtmltoimage-amd64
    [3] => wkhtmltoimage-i386
)
Array
(
)
显然,我甚至不确定错误来自何处。可能是路径错误,或者输入有点错误,但我不知道如何得到这些因素的任何输出。甚至函数似乎也没有通过数组返回任何输出行


我如何调试这个?我从哪里开始?是否有用于检查目录或文件执行的PHP函数?

愚蠢的错误,我必须使用根路径。(例如,
/home/…


是否有人觉得web开发的一半时间都浪费在解决路径问题上了?Grrr.

不确定这是否有帮助,但我不得不将stderror重定向到stdout:$blah=shell_exec($cmd 2>&1”);那可能会帮助你。