<?php
class Foo {
const BAR = 1;
protected $message = BAR;
public function __construct($message) {
$this->message = $message;
echo "Initialized with {$this->message}";
}
}
$var = new Foo(Foo::BAR);
Fatal error: Uncaught Error: Undefined constant "BAR" in /in/28Pg6:16
Stack trace:
#0 {main}
thrown in /in/28Pg6 on line 16
Process exited with code 255.
Warning: Use of undefined constant BAR - assumed 'BAR' (this will throw an Error in a future version of PHP) in /in/28Pg6 on line 16
Initialized with 1
Notice: Use of undefined constant BAR - assumed 'BAR' in /in/28Pg6 on line 16
Initialized with 1
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/28Pg6 on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/28Pg6 on line 5
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/28Pg6 on line 5
Process exited with code 255.