PHP Class Property Using range()
oop, php
Solution
You can only assign constant values in that context. You'll have to initialize your `$foo` in a constructor if you want to use the return value of a function.
<?php
class What {
public $foo;
public function __construct() {
$this->foo = range(0,5);
}
}
?>
BTW: As others have pointed out, `array()` is not a function. It's a language construct.
Problem
Here is a minimal test case I've isolated: ``` <?php class What { public $foo = range(0,5); } ?> ``` I have no idea why this produces an error: PHP Parse error: syntax error, unexpected '(', expecting ',' or ';' in TestCase.php on line 4 Using `array()` works. Using PHP 5.3.3 (bundled with OS X).