professional-php-05-class.dog.php / php
<?php class Dog { private name) { name; } public function bark() { if(isset(this->_onspeak)) { return false; } } print "Woof, woof!"; } public function onspeak(objOrClass = null) { if(callback = array(functionName); } else { functionName; } //make sure this stuff is valid if(!is_callable(callableName)) { throw new Exception("this->_onspeak = //end class Dog //procedural function function isEveryoneAwake() { if(time() < strtotime("today 8:30am") || time() > strtotime("today 10:30pm")) { return false; } else { return true; } } objDog = new Dog('Fido'); objDog->bark(); //polite dog objDog2->bark(); //always barks! //Throws exception when onspeak is called. objDog3->onspeak('nonExistentFunction', 'NonExistentClass');
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.