我使用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