我使用Codeigniter来构建我的项目。PHP-Codeigniter中的构造函数
这里我有一些疑惑或需要一些澄清。
我可以使用构造函数做一些影响codeigniter/php中所有其他函数的事情吗?
请看看这里:
<?php
class New extends CI_Controller
{
function __construct()
{
//Constructor codes...
}
function Create_page() //The user need to be Logged in to perform this
{
//Checking whether the user logged in or not if yes allowed else denied.
}
function Edit_page() //The user need to be Logged in to perform this
{
//Checking whether the user logged in or not if yes allowed else denied.
}
function Delete_page() //The user need to be Logged in to perform this
{
//Checking whether the user logged in or not if yes allowed else denied.
}
function about_us() //This is a public action no need to Log in
{
// this is a pulic action ,no need to check the login status
}
}
?>
正如你可以看到,我需要检查每私有函数状态记录下来,
有什么办法,我可以做到这一点的构造?使构造将审核登录或没有....但只需要影响某些功能......
有所有公共职能 – ajreal 2011-12-15 13:03:34
@ajreal这是合乎逻辑的。 – Red 2011-12-15 13:13:42