Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter BASEPATH

Hi I am new to Codeigniter. From my understanding of the BASEPATH, it is used to activate the Codeigniter framework. The code

defined('BASEPATH') OR exit('No direct script access allowed');

is used at top of the page to prevent direct access to the controller. But it is not working in my code. When I try to directly access a view via controller, the view gets loaded. I have checked index.php and BASEPATH is defined there. Please advice.

like image 922
John Avatar asked Nov 18 '14 08:11

John


1 Answers

defined('BASEPATH') OR exit('No direct script access allowed'); is used to make sure that the request has gone through index.php in your root dir. This is for reasons such as making sure that all Codeigniter base classes are being loaded and making sure certain vars have been set etc.

So, yes you will be able to access a view file if you're going through a controller.

Hope this helps!

like image 119
Rwd Avatar answered Oct 05 '22 11:10

Rwd