Hola a todos, estoy haciendo unas pruebas pero este codigo me da error, porquE?
el error que me da es esta
Fatal error: Cannot access empty property in D:\xampp\htdocs\prueba\index.php on line 12
Gracias de antemano
Saludos
Código:
<?php
$a = new prueba();
$a->inicia();
$a->recorrer();
class prueba
{
static $numIndex;
function inicia()
{
$this->$numIndex = 0;
}
function recorrer()
{
while ($this->$numIndex < 10)
{
if (($this->$numIndex%2)==0)
{
echo $this->$numIndex, 'No', '<br>';
$this->recorrer();
}
else
echo $this->$numIndex, 'Si', '<br>';
}
}
}
?>