Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi, I have a simple codeCode: Select all
class Mes{
var $dias=0;
var $nombre;
function Mes($nombre,$dias) {
$this->nombre=$nombre;
$this->dias=$dias;
}
function dias() {return $this->dias;}
function nombre() {return $this->nombre;}
}
class Anio {
var $meses;
static $diasSemana=Array("L","M","X","J","V","S","D");
function Anio() {
$meses=Array(
new Mes("Enero",31),
new Mes("Febrero",28),
new Mes("Marzo",31),
new Mes("Abril",30),
new Mes("Mayo",31),
new Mes("Junio",30),
new Mes("Julio",31),
new Mes("Agosto",31),
new Mes("Septiembre",30),
new Mes("Octubre",31),
new Mes("Noviembre",30),
new Mes("Diciembre",31)
);
}
function mes($n) {return $this->meses[$n];}
function diasem($n) {return $this->diasSemana[$n];}
}
$a=new Anio();
echo($a->mes[0]->nombre());PHP Fatal error: Call to a member function nombre() on a non-object in .... (in the final echo).
Can anyone tell me how can I make this? I'm using PHP5.
Thank you!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]