Jump to content

PieceOfMeat

New Members
  • Posts

    1
  • Joined

  • Last visited

PieceOfMeat's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.