php concatenating string to classconstant in array assignment

following doesn't work:

<?php
class test{
    const t = 10;
    public static $y = array('t' => self::t . 'hello');
}
var_dump(test::$y);
?>

can somebody tell me why that is? :)

it fails in the ... => self::t . 'hello')... part, where it, as seams, not is able to concatenate a classconstant in the array().

that implies that both of following works perfect:

public static $y = array('t' => self::t);

and

public static $y = array('t' => 'hello');

Answers


can somebody tell me why that is?

Concatenation is a product of run-time. Class member initial values must be known at parse time.


Need Your Help

How to generate a random string in Ruby

ruby random passwords

I'm currently generating an 8-character pseudo-random uppercase string for "A" .. "Z":

Random number generator method for linked list assignment

java arrays random generator

So, I have to make a random number generator to get numbers ranging from 0 to 400. I'm putting these into an array and then sorting them later on. I just am not sure how to go about doing this. ...