简体   繁体   English

在Codeigniter / PHP中的子目录中放置私有功能不起作用

[英]Placing Private Function in Subdirectories in Codeigniter/PHP not working

I am utterly and completely confused. 我完全感到困惑。 I've looked through all the documentation and I can't find a solution. 我已经浏览了所有文档,但找不到解决方案。 Setup: CI 2.1.3, QNAP server. 设置:CI 2.1.3,QNAP服务器。

Problem: I cannot use a private function on a controller: 问题:我无法在控制器上使用私有功能:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Signup extends CI_Controller {

public function index()
{
    _loadcontent();
}

private function _loadcontent()
{
        $this->load->view('welcome_message');
}
}

/* End of file signup.php */
/* Location: ./application/controllers/account/signup.php */

it won't work and gives an HTTP Error 500 (Internal Server Error). 它无法正常工作,并给出HTTP错误500(内部服务器错误)。 HOWEVER, placing the file in the main controller directory works. 但是,将文件放置在主控制器目录中是可行的。 Does anybody have any clue? 有人有任何线索吗? is this a bug? 这是一个错误吗? Thanks in advance. 提前致谢。

You need to call the function using $this . 您需要使用$this调用该函数。

public function index()
{
    $this->_loadcontent();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM