So this is my class file ---------------------- <?php Class Config { private static $_config_array = array( 'dbhost' => 'localhost', 'dbname' => 'practice', 'dbuser' => 'root', 'dbpass' => 'mysql' ); public static function get($dbkey) { return $_config_array[$dbkey]; } } ?> PHP: ------------------ this is where I am trying to sort of debug ------------------ <?php include 'Config.php'; var_dump(Config::get(dbhost)); ?> PHP: ------------------- What I was expecting to get is "localhost", but I am getting NULL. As you can see I am very new to all of this
you'll kick yourself public static function get($dbkey) { return $this->_config_array[$dbkey]; } PHP:
any ideas as to why this is telling me that I have an unexpected { spl_autoload_register(function ($class) { include 'classes/' . $class . '.class.php'; }); the php documentation says that I should be able to put an anonymous function in here...
I've never used them - not a fan of them in js either but that's me showing my age, I guess. From looking at the docs I can see there can be value in using them - but I'm not sure including all your class files quite what they had in mind. @PoPSiCLe will probably know. What error are you getting?
ok I found out what the issue is... something is up with the server software that I am using. when I do a phpinfo() it says I am running 5.6... but when I check the version in the terminal it says 5.3 which is not compatible with anonymous functions
What PHP version are you running? Anonymous Functions (http://php.net/manual/en/functions.anonymous.php) are available as of version 5.3 or higher. A good website to test code on multiple versions: http://sandbox.onlinephpfunctions.com/