Sometime we don't need to execute any method / code inside constructor/destructor.
example for codeigniter
class Student
{
if (in_array(uri_string(), $exception_uris) == FALSE)
{
if ($this->student_m->loggedin() == FALSE)
{
example for codeigniter
class Student
{
public function __construct ()
{
// we want to skip 2 methods(login and logout) in this 'student' class.
$exception_uris = array(
'student/login',
'student/logout'
);
// check called class and method from URL.If called method are not those login/logout execute code
// check called class and method from URL.If called method are not those login/logout execute code
if (in_array(uri_string(), $exception_uris) == FALSE)
{
if ($this->student_m->loggedin() == FALSE)
{
redirect('student/login');
}
}
}
}
No comments:
Post a Comment