Hi,
I have an error in a class I typed, and I don't know why. My code is the following:
class Persona
{
private $nombre;
private $apellidos;
function __construct()
{
$nombre="David";
$apellidos="Garcia Roma";
}
function getNombre()
{
return $nombre."<br>";
}
function getApellidos()
{
return $apellidos."<br>";
}
};
$persona = new Persona();
print $persona->getNombre();
When I load the script in my webserver I display the following error:
Undefined variable: nombre in C:\wamp\www\DatosPersonas.php on line 33
How can I fix this error?
Thanks.