CodeIgniter错误解决

时间:2014-01-07 19:03:44

标签: php codeigniter

我是CodeIgniter的新用户。首先我安装CodeIgniter,然后编写以下代码并尝试在浏览器的帮助下运行它。我将程序保存在htdocs/application/controllers/hello.php中,但它显示错误:

  

警告:define()需要至少2个参数,1在第2行的D:\ xampp \ htdocs \ ci_intro \ hello.php中给出

     

不允许直接访问脚本。

有什么问题?

<?php 
if(!define('BASEPATH','')) exit('no direct script access allowed');
class Hello extends CI_Controller{
public function index()
{
    echo "this is my index function";
}
    public function one()
    {
       $this->load->view('one');
    }
}
?>

1 个答案:

答案 0 :(得分:4)

应该是defined而不是define

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