ThinkPHP 3.2.3
在Application\Common\Common\function.php中怎么实例化一个ThinkPHP\Library\Vendor\YPP\Page.class.php中的Page类?
我尝试了:
$p = new Vendor\YPP\Page($count, $pagsize=10);
结果提示:
Class 'Vendor\YPP\Page' not found
按照网上的说法,‘在Controller或function中使用第三方扩展时,就可以直接使用vendor()方法来进行引用了。’
那为什么还会报错呢?
Vendor('YPP.Page');
$p = new \Page($count,$pagsize);
当然这种调用的方式是前提你的第三方类库是放置在thinkPHP核心包的三方类库目录下
import('Vendor.YPP.Page');
$p = new \Page($count,$pagsize)
function里没有自动加载
所以要include这个类在实例化