In the php manual, it is stated in user contributed notes that const array is now allowed. I even checked other posts here in stackoverflow and they said the same. I tested the following code:
<?php
class Constants{
const test = array("a"=>"apple","b"=>"ball","c"=>"car");
}
echo Constants::test["b"];
echo Constants::test["c"];
echo Constants::test["a"];
?>
Output:
ball
car
apple
The above code works. However This doesn't work if I use define('test',array("a"=>"apple","b"=>"ball","c"=>"car")
outside of the class. Is this a new undocumented change or happening only in my setup?
My setup is php 5.6.1(32-bit thread safe) and apache 2.4.10 (32-bit) on windows 7 x64. I downloaded them from the their respective sites directly. I didn't use any WAMP stacks.
Also note that I am using netbeans 8.0.1 IDE for hints and it shows this error. Anyone know how to remove it?
Syntax error
unexpected: [
after: identifier 'test'
expected: instanceof, as, =>, }, ',', OR, XOR, &&, ?, ;, ||, &&, |, ^, &, ==, !=, ===, !==, <=,
>=, <, >, <<, >>, +, -, *, /, %, '.', ], (, ), :
----