首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wkhtmltoimage和PHP调试

wkhtmltoimage和PHP调试
EN

Stack Overflow用户
提问于 2011-06-09 02:51:30
回答 1查看 4.1K关注 0票数 1

我正在尝试使用PHP中的wkhtmltoimage来抓取屏幕。它不工作,但我不知道如何调试它。我联系了我的服务器管理员,他们说允许使用exec。下面是我的目录结构:

代码语言:javascript
复制
-index.php
-lib/
  -screenshot.php
  -wkhtmltoimage/
     -wkhtmltoimage-i386
     -wkhtmltoimage-amd64

screenshot.php中的代码如下:

代码语言:javascript
复制
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调用url上的函数screenshot "http://www.nasa.gov/"“。

下面是我得到的输出:

代码语言:javascript
复制
Array
(
    [0] => .
    [1] => ..
    [2] => wkhtmltoimage-amd64
    [3] => wkhtmltoimage-i386
)
Array
(
)

显然,我甚至不确定错误来自哪里。可能是路径错误,也可能是输入错误,但我不知道如何获得这些因素的任何输出。即使这个函数似乎也没有通过我的数组返回任何输出行。

我如何调试它呢?我该从哪里开始呢?有没有用来检查目录或文件执行的PHP函数?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-20 11:14:33

愚蠢的错误,我不得不使用根路径。(例如/home/...)

有没有人觉得web开发中一半的时间都浪费在解决路径问题上?Grrr。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6283708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档