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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With