PHP const and static variables

In addition to that const variables can’t be changed, another difference between const and static is that some variables like arrays are not allowed in class constants, so

class mytest
{
public static $c = array(1=> 'hello', 2=>'world');
}

works, but

class mytest
{
const c = array(1=> 'hello', 2=>'world');
}

won’t.

Leave a Reply