I got this PHP error from the Codeigniter Email.php class called CI_Email:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class CI_Email { var $smtp_default_from = ''; var $smtp_default_name = ''; var $useragent = "CodeIgniter"; var $mailpath = "/usr/sbin/sendmail";
I tried to include this class directly as follows:
<?php include("Email.php"); ?>
And when I run it, it says:
No direct script access.
The PHP method "defined" checks if a given constant exists or is not defined.
So, for my specific class, it says that BASEPATH should be defined. Therefore, if you define it as follows:
<?php define('BASEPATH', "foobar"); include("Email.php"); ?>
Then the error will no longer be selected. But then we need to ask ourselves why developers ask this particular restriction and what happens if we get around it.
source share