Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

var for a class in PHP

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.69 KB  |  views: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class flexibleAccess{
  2.  
  3.   var $dbName = 'mydatabase';
  4.        
  5. class flexibleAccess{
  6.  
  7.       var $dbName = $_SESSION['mydatabase'];
  8.        
  9. class flexibleAccess{
  10.  
  11.    private $dbName;
  12.  
  13.    function __construct() {
  14.          $this->dbName = $_SESSION['mydatabase'];
  15.    }
  16. }
  17.        
  18. constant("DBNAME", 'mydatabase');
  19.        
  20. require_once 'dbconfig.php';
  21.  
  22. class flexibleAccess {
  23.   private $dbname;
  24.  
  25.   // set the default database name to the constant DBNAME
  26.   // but allow override
  27.   public function __construct ( $dbname = DBNAME )
  28.   {
  29.     $this->dbname = $dbname;
  30.   }
  31. }
  32.        
  33. require_once 'flexibleaccess.php';
  34.  
  35. $db = new flexibleaccess();
  36.        
  37. <?php
  38. $login = new flexibleAccess();
  39. $login->dbName = $_SESSION['mydatabase'];
  40. ?>
clone this paste RAW Paste Data