Prev | Current Page 258 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Its prototype follows:
boolean is_subclass_of(object object, string class_name)
Determining Method Existence
The method_exists() function returns TRUE if a method named method_name is available to
object, and returns FALSE otherwise. Its prototype follows:
boolean method_exists(object object, string method_name)
Autoloading Objects
For organizational reasons, it??™s common practice to place each class in a separate file.
Returning to the library scenario, suppose the management application calls for classes
representing books, employees, events, and patrons. Tasked with this project, you might
create a directory named classes and place the following files in it: Books.class.php,
Employees.class.php, Events.class.php, and Patrons.class.php. While this does
indeed facilitate class management, it also requires that each separate file be made
available to any script requiring it, typically through the require_once() statement.
Therefore, a script requiring all four classes would require that the following statements
be inserted at the beginning:
192 CHAPTER 6 ?–  O BJECT-ORIENTED PHP
require_once("classes/Books.class.php");
require_once("classes/Employees.class.php");
require_once("classes/Events.class.php");
require_once("classes/Patrons.class.php");
Managing class inclusion in this manner can become rather tedious and adds an
extra step to the already often complicated development process.


Pages:
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270