View Single Post
ישן 11-05-11, 21:11   # 2
בניה
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
מיקום: נחושה
הודעות: 3,434

בניה לא מחובר  

אתה יכול לעשות משהו כזה:
PHP קוד:
<?php
class app {
    
    static public 
$db;
    
    
    public static function 
init() {
        
//you can add here more functionality  
        
self::$db = new DB();
        
self::$db->connect();
    }
    
    public static function  
getDb() {
        return 
self::$db;
    }
    
}

//page startup:
app::init();

//i want to use db inside a function:
function use_db() {
    
    
$db app::getDb();
    
    
$db->query();
}
?>
  Reply With Quote