在api/uc.php中,即非index.php入口文件中,怎么调用ci的一个类
本帖最后由 viqecel 于 2013-7-12 23:03 编辑application\libraries\Auth.php
类似这样吗
require_once BASEPATH.'./core/CodeIgniter.php';
require APPPATH.'./libraries/Auth.php';
$auth = new auth();
$auth->login();
本帖最后由 viqecel 于 2013-7-13 09:02 编辑
要用路由.把uc.php转到index.php/uc
头痛的是怎么在uc.php整合接口中,调用session类,并入库等
require_once BASEPATH.'./core/CodeIgniter.php';
require APPPATH.'./libraries/Auth.php';
$auth = new auth();
$auth->login();
不明白你说不走CI入口,但是却 require_once BASEPATH.'./core/CodeIgniter.php';
1:
你在非CI入口中是不能直接使用BASEPATH,APPPATH常量,要自己定义好:
2,:require_once BASEPATH.'./core/CodeIgniter.php';
实际上已经直接走了CI的入口了
3,既然引用了CI核心,就得按照CI的规则来,不是你直接require就行
如果你不能想使用CI的机制
可以这样
require_once BASEPATH.'./core/Common.php';
$auth = &load_class('Auth');
$auth->login();
值得注意的是CI里的类有可能与CI有千丝万缕的关系,所以你单独调用分分钟都可能出bug
你要整合UCenter到CI里,建议规划一下运行机制,不然得不偿失的哟 gogogo1027 发表于 2013-7-13 12:06 static/image/common/back.gif
不明白你说不走CI入口,但是却 require_once BASEPATH.'./core/CodeIgniter.php';
1:
你在非CI入口中是 ...
要剥离出session类出来.单独使用了
不明白LZ用意。。要使用CI的session类,在控制器里调用uc接口,返回数据后用session存储不就行了
页:
[1]