php codeIgniter 框架引入第三方类库文件

在application/helpers下创建一个php文件,文件名取为mytest_helper.php,文件名必须以_helper结尾。

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Date: 2017/2/8
  5. * Time: 21:08
  6. * @param $data
  7. * @return string
  8. */
  9. function test_helper($data)
  10. {
  11. return 'the data is'.$data;
  12. }
  13. ?>

<2>在controller里这样调用:

  1. $this->load->helper( 'mytest');
  2. echo test_helper( 'hello');

猜你喜欢

转载自blog.csdn.net/wide288/article/details/80983877