0

我正在尝试创建一个简单的模块来测试事情,每当我转到模块页面http://mysite.com/testmodule时,我都会收到“禁止访问,拒绝访问”错误。

该模块唯一要做的就是回显一个测试字符串:

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

class testmodule extends Public_Controller
{
 /**
  * Constructor method
  *
  * @author PyroCMS Dev Team
  * @access public
  * @return void
  */

 public function __construct()
 {
  parent::__construct();
  echo 'test';


}


}

知道为什么会发生这种情况吗?

4

1 回答 1

1

我对 PyroCMS 并不太熟悉(例如,一点也不),但它基于 Codeigniter ......在这种情况下,以下内容似乎可能会有所帮助。抱歉,如果它们不适合 PyroCMS。

像这样再试一次:

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

    class Testmodule extends Public_Controller
    {
     /**
      * Constructor method
      *
      * @author PyroCMS Dev Team
      * @access public
      * @return void
      */

     public function __construct()
     {
      parent::__construct();  
     }


    public function index()
    {
      echo 'Test';
    }
}

您的问题可能是:1)您在构造函数中而不是在默认函数中回显 2)您的类名不是以大写字母开头

希望有帮助!

于 2011-05-02T14:59:39.050 回答