我的情况是:
码
第一行:
include('/opt/lampp/htdocs/myproject/application/controllers/myFile.php');
此脚本正在运行后台程序。
function procmsg($topic,$msg){
//do something...
//my_function() is a function in the myFile.php script
my_function(true, $userGtwy, $passwdGtwy, $node_id, $idGateway, $value, $rssi);
}
myFile.php
此脚本的第一行:
require(APPPATH.'/libraries/REST_Controller.php');
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
功能:
public function my_function($flag=false, $usr, $pass, $node, $gateway, $val, $freq){}
当我运行我的第一个脚本时,我得到:
PHP Notice: Use of undefined constant APPPATH - assumed 'APPPATH' in /opt/lampp/htdocs/myproject/application/controllers/myFile.php on line 3
PHP Warning: require(APPPATH/libraries/REST_Controller.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/myproject/application/controllers/myFile.php on line 3
PHP Fatal error: require(): Failed opening required 'APPPATH/libraries/REST_Controller.php' (include_path='.:/usr/share/php') in /opt/lampp/htdocs/myproject/application/controllers/myFile.php on line 3
并且,如果我评论这一行:
require(APPPATH.'/libraries/REST_Controller.php');
我得到:
No direct script access allowed
我需要这个库,我需要使用我的脚本访问,请帮助我!
我发现了这个:Access Codeigniter functions from external script 但我不明白......
我的问题,我可以这样做吗?还是不可能?