我试图从控制器文件调用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/vendor
和simple-html-dom.php
文件。utils.php
是file_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");