+ 3
Why there is fatal error?
5 ответов
+ 5
Because you assigned an expression and it's not allowed. Static variable and properties may only be initialized using a literal or a constant.
+ 3
AJ/AY yes, it works
+ 3
Thanx
+ 2
Because you used static keyword with variable and assigned to it's expression. You can use static to initialize the variable only. static also can be use with constant value and function.
Put this and check again.
<?php
//$int = sqrt(100);
static $int = 0;
$int = sqrt(100); //fatal error
echo $int;
?>
+ 1
Welcome