Php 如何在CodeIgniter helper中调用函数内部函数
我想访问code igniter helper中函数内部的函数您可以使用CI helpers中的任何函数。如果要向现有帮助器添加新函数,则必须扩展该帮助器 手册上都有: 以下是该链接的摘录:Php 如何在CodeIgniter helper中调用函数内部函数,php,codeigniter,email,Php,Codeigniter,Email,我想访问code igniter helper中函数内部的函数您可以使用CI helpers中的任何函数。如果要向现有帮助器添加新函数,则必须扩展该帮助器 手册上都有: 以下是该链接的摘录: // any_in_array() is not in the Array Helper, so it defines a new function function any_in_array($needle, $haystack) { $needle = is_array($needle) ? $
// any_in_array() is not in the Array Helper, so it defines a new function
function any_in_array($needle, $haystack)
{
$needle = is_array($needle) ? $needle : array($needle);
foreach ($needle as $item)
{
if (in_array($item, $haystack))
{
return TRUE;
}
}
return FALSE;
}
// random_element() is included in Array Helper, so it overrides the native function
function random_element($array)
{
shuffle($array);
return array_pop($array);
}
您可以在另一个函数中使用帮助器函数,前提是您已加载/扩展该帮助器,并且要使用的函数不是私有的。 你有没有试过这样的方法: 助手
帮助器是全局的,因此只要先加载了帮助器,就可以在代码中的任何位置使用帮助器函数。您可以在控制器的构造函数中加载助手:$this->load->helper'new_helper' 函数hello1{$this->hello2;}函数hello2{echo'hi';}
funtion helper1($var) {
$CI =& get_instance();
/** you cannot use $this inside helper */
// call another function
helper_function2();
}