在application/helpers下创建一个php文件,文件名取为mytest_helper.php,文件名必须以_helper结尾。
-
-
/**
-
* Created by PhpStorm.
-
* Date: 2017/2/8
-
* Time: 21:08
-
* @param $data
-
* @return string
-
*/
-
function test_helper($data)
-
{
-
return 'the data is'.$data;
-
}
-
<2>在controller里这样调用:
-
$this->load->helper( 'mytest');
-
echo test_helper( 'hello');