tags:

views:

229

answers:

1

How can I access a static variable in a separate class in PHP? Is the scope resolution operator the wrong tool for the job? Example:

class DB {
  static $conn = 'Connection';
}



class User {
  function __construct() {
    DB::conn; //throws "Undefined class constant 'conn' error.
  }
}
+8  A: 
DB::$conn

You need the $ before the variable name if it's a property.

dirtside
Ha, I need to call it a day. Switching between C# and PHP is making me totally overlook pesky missing $ signs! Thanks for the quick catch dirtside!
Cory House