02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

public function __construct()<br />

{<br />

echo 'The class "', __CLASS__, '" was initiated!';<br />

}<br />

public function __destruct()<br />

{<br />

echo 'The class "', __CLASS__, '" was destroyed.';<br />

}<br />

public function __toString()<br />

{<br />

echo "Using the toString method: ";<br />

return $this->get<strong>Pro</strong>perty();<br />

}<br />

public function set<strong>Pro</strong>perty($newval)<br />

{<br />

$this->prop1 = $newval;<br />

}<br />

private function get<strong>Pro</strong>perty()<br />

{<br />

return $this->prop1 . "";<br />

}<br />

public static function plusOne()<br />

{<br />

return "The count is " . ++self::$count . ".";<br />

}<br />

class MyOtherClass extends MyClass<br />

{<br />

public function __construct()<br />

{<br />

parent::__construct();<br />

echo "A new constructor in " . __CLASS__ . ".";<br />

}<br />

}<br />

public function newMethod()<br />

{<br />

echo "From a new method in " . __CLASS__ . ".";<br />

}<br />

public function call<strong>Pro</strong>tected()<br />

{<br />

return $this->get<strong>Pro</strong>perty();<br />

}<br />

CHAPTER 3 ■ OBJECT-ORIENTED PROGRAMMING<br />

109

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!