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. } }
DB::$conn
You need $ in front of the variable name if it's a property.