 |
|
ss
Oracle Tips by Burleson |
OO Magic
As in any OO implementation, there are few
specific functions that perform special tasks. For example, the _autoloadfunction is used to load the required class definition functions into
the executing script. In example13.php, there is the following
line:
require_once('OCI_Session.php');
If there are several classes, each in its own
definition file, those definition files have to be included into the
script, each with its own ‘require_once’ line.
This can be awkward and cumbersome. If the PHP
interpreter cannot find the definition of a given class $class_name,
it will first try to execute function __autoload
($class_name). If the class $class_name is still not
defined, the script will be terminated. Thus, the function is defined
like this:
function __autoload
($class_name) {
require_once($class_name.'.php');
}
In example13.php, the programmer forgot to
include OCI_Session.php. The script still works because the
definition of the class OCI_Session is still included when the
class is used. If all class definitions are kept in the files that
have the same name as the class that is defined, it becomes
unnecessary to write include statements for them as long as the
function __autoloadin its above form
exists within the script. Of course, the __autoload function
can also be placed in an include file.
There are additional special functions in the PHP
5 object model that are outside the scope of this book. The next
important part of this chapter deals with sessions.
See
code depot for complete scripts
The above book excerpt is from:
Easy Oracle
PHP
Create Dynamic Web Pages with Oracle Data
ISBN
0-9761573-0-6
Mladen Gogala
http://www.rampant-books.com/book_2005_2_php_oracle.htm
|