name = $newName; $this->street = $newStreet; $this->city = $newCity; $this->state = $newState; $this->zip = $newZip; } public function display(){ echo "

Address Entry

\n"; echo "

\n"; echo "Name: " . $this->name . "
\n"; echo "Street: " . $this->street . "
\n"; echo "City: " . $this->city . "
\n"; echo "State: " . $this->state . "
\n"; echo "Zip: " . $this->zip . "
\n"; echo "

\n"; } function __call($method, $arguments) { $prefix = strtolower(substr($method, 0, 3)); $property = strtolower(substr($method, 3)); if (empty($prefix) || empty($property)) { return; } if ($prefix == "get" && isset($this->$property)) { return $this->$property; } if ($prefix == "set") { $this->$property = $arguments[0]; } } } ?> PHP Address Object

PHP Address Object

Create an object and display it.

display(); ?>

Change the object contents and display them.

setName("Jane Doe"); echo "

New name is: " . $anAddress->getName() . "

\n"; $anAddress->setCity("Los Angeles"); echo "

New city is: " . $anAddress->getCity() . "

\n"; $anAddress->setState("CA"); echo "

New state is: " . $anAddress->getState() . "

\n"; $anAddress->display(); ?>