lundi 31 mai 2021

"Constant expression contains invalid operations" when initialize variable laravel [duplicate]

When I initialize a global variable with rand(), get this error on rand():

Constant expression contains invalid operations

This is my code:

class registerController extends Controller {

public $conto = rand(100,999);

public function create()
{ 
 ...
 $conto = $this->conto;
 ...    
}
public function countErrors() 
{
...
$conto = $this->conto;
}



Aucun commentaire:

Enregistrer un commentaire