so i would
Code:
self::$m_pInst = new self();
but when i call i would use
Code:
$EvulSys = EvulSession::getInst();
then when ever i need to use the methods from session in sys, i would just call something like...
$EvulSys->set_var("user_name", "Guest");
hows this look...
I am still writing it up on my linux box, but this is what i have so far, haven't tested what i have, but if i'm understanding things right... my next post will be saying it worked :)
Evuldb.php
Code:
<?php
class Evuldb{
private static $EvInst;
//construct & Connect to $host immediatly
function __construct(){
$this->Connect();
}
public static function getInst(){
if (!self::$EvInst) self::$EvInst = new self();
return self::EvInst;
}
function Connect () { .. connect stuff... }
//other methods etc...
}
?>
EvulSess.php
Code:
<?php
class EvulSession {
private static $EvInst;
//construct class & Start a session immediatly
function __construct(){
session_start();
}
public static function getInst(){
if (!self::$EvInst) self::$EvInst = new self();
return self::EvInst;
}
//other methods for session bwlow
}
?>
and Evulsys.php
Code:
<?php
include_once 'Evuldb.php';
include_once 'EvulSess.php';
class EvulSys extends Evuldb {
// declare variables
var $EvulSys;
public static $EvSession;
public static $EvDbase;
//construct & set session & Connect to DB
function __construct(){
$EvSession = EvulSession::getInst();
$EvulSys = $this->Connect();
}
//do login & other methods
}
?>
oh, i was thinking... i don't HAVE to do that on construct right? i can do that at anytime, in any method? and the instance will only be loaded and used when the method i use, sets the ::getInst()?