10-19-2012, 06:07 AM
[eluser]Unknown[/eluser]
I'm experiencing codeigniter for the first time, yet I've been programming in PHP since '02 or so. I have gone through some tutorials, and get the basic structure and I love it!
As a first-dev I'm going to throw up basic "user system" functionality. How is it preferred to go out about using frequently used functions/ classes such as a User class? Should you extend the User class on every page that you will use it? as such: (note this isn't my actual code, just testing theory.
controllers/user.php
controllers/homepage.php
I'm experiencing codeigniter for the first time, yet I've been programming in PHP since '02 or so. I have gone through some tutorials, and get the basic structure and I love it!
As a first-dev I'm going to throw up basic "user system" functionality. How is it preferred to go out about using frequently used functions/ classes such as a User class? Should you extend the User class on every page that you will use it? as such: (note this isn't my actual code, just testing theory.
controllers/user.php
Code:
class User extends CI_Controller
{
function __construct() {
parent::__construct();
}
function auth_level() {
//gets users info and returns auth level
}
}
controllers/homepage.php
Code:
class Homepage extends User
{
function __construct() {
parent::__construct();
}
function index() {
if($this->auth_level() > 2) {
echo "admin";
}
}
}