我试图从控制器文件调用cakephp中的第三方库函数。
我的控制器文件中有这个:

public function index() {
    App::import('vendor', 'simple-html-dom.php');
    App::import('vendor', 'utils.php');

    set_time_limit(0);

    $html = file_get_html("google.com");
    ...
}

我还有app/vendorsimple-html-dom.php文件。
utils.phpfile_get_html中的公共函数(它不属于任何类)。最后我犯了个错误:
Error: Call to undefined function file_get_html()

我一直在寻找解决这个问题的方法,但一直没有找到答案。

最佳答案

我在工作。试试这个,

App::import('Vendor', 'simple_html_dom', array('file'=>'simple_html_dom.php'));

$html = file_get_html("google.com");

09-10 06:54
查看更多