Alex wood Alex wood - 3 months ago 17
PHP Question

Codeigniter error : define() expects at least 2 parameters

I got a strange error in Codeigniter error : define() expects at least 2 parameters in Line 1.

What is wrong with my code below

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

class Login extends CI_controller {

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

public function index(){
$this->load->view('login_view');
}
}

Answer

I think your looking for the function: defined()

With define() your defining a constant!

With defined() your checking if a constant is defined!

So try this:

!defined('BASEPATH')