<?php
// Only the static methods shall be called using the static call syntax
error_reporting(-1);
class Config {
protected static $config = array();
public function get($name) {
return static::$config[$name];
}
public function set($name, $value) {
static::$config[$name] = $value;
}
}
Config::set("xxx", "yyy"); // Error - Config::set is not marked as static
print(Config::get("xxx")."\n"); // Error - Config::get is not marked as static
Fatal error: Uncaught Error: Non-static method Config::set() cannot be called statically in /in/Bu0Pj:19
Stack trace:
#0 {main}
thrown in /in/Bu0Pj on line 19
Process exited with code 255.
Deprecated: Non-static method Config::set() should not be called statically in /in/Bu0Pj on line 19
Deprecated: Non-static method Config::get() should not be called statically in /in/Bu0Pj on line 20
yyy
Strict Standards: Non-static method Config::set() should not be called statically in /in/Bu0Pj on line 19
Strict Standards: Non-static method Config::get() should not be called statically in /in/Bu0Pj on line 20
yyy
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC in /in/Bu0Pj on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STATIC in /in/Bu0Pj on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Bu0Pj on line 8
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Bu0Pj on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/Bu0Pj on line 8
Process exited with code 255.