我想從一個common_helper.php文件調用核心php文件中的函數,該文件位於codeigniter的application/helpers文件夾中。在助手文件中被接收到的函數也用於成員控制器中。所以在codeigniter網站這是工作。但不是在PHP核心是outside.Please幫我如何從常用助手外部應用程序文件夾調用函數?
文件結構:
項目/ test.php的
應用/控制器/會員
應用程序/傭工/ common_helper.php
這裏是我的common_helper.php
function reg_code()
{
$CI =& get_instance();
echo "in registration_code";
$registration_code = get_reg_code();
return $registration_code;
}
function check_code($registration_code)
{
$CI =& get_instance();
$sql = "SELECT * FROM membership WHERE reg_code = '$registration_code'";
$query = $CI->db->query($sql);
if($query->num_rows() > 0){
return FALSE;
}else{
return TRUE;
}
}
function get_reg_code()
{
$CI =& get_instance();
$CI->load->helper('string');
$alha_result = random_string('alpha',1);
$numeric_result = random_string('numeric',3);
$reg_code = $alha_result.$numeric_result;
$reg_code = strtoupper($reg_code);
//check if code exists
if(check_code($reg_code)){
return $reg_code;
}else{
get_reg_code();
}
return $reg_code;
}
test.php的
include_once "../application/helpers/common_helper.php";
$reg = reg_code();
echo "Reg Code :".$reg;
首先檢查您的文件'common_helper.php'是否已加載... –
是它的加載因爲我有被調用的電子郵件功能。即使在這些功能回聲。但我想fordb訪問有一些我不知道的。@ Praveen – piya