Hello everyone
This is my code:
<?php
class Customer
{
public $name = "name";
public $phone = "phone";
public $mail = "mail";
public function setName($n)
{
$this->name = $n;
}
public function getName()
{
return $this->name . "<br />";
}
public function setPhone($p)
{
$this->$phone = $p;
}
public function getPhone()
{
return $this->$phone . "<br />";
}
public function setMail($m)
{
$this->$mail = $m;
}
public function getMail()
{
return $this->$mail . "<br />";
}
}
$a = new Customer;
echo $a->getName();
echo $a->getPhone();
echo $a->getMail();
$a->setName("A");
$a->setPhone("2818");
$a->setMail("gmail.com");
echo $a->getName();
echo $a->getPhone();
echo $a->getMail();
?>
for some reason i get error for the phone and mail variables:
Notice: Undefined variable: phone in /home/stud/2011/3/avile/public_html/ex1a/index.php on line 26 Fatal error: Cannot access empty property in /home/stud/2011/3/avile/public_html/ex1a/index.php on line 26
But i dont get this error for the name variable. Is somebody know why?