Searching...
Saturday 13 October 2012

Autoloading In PHP

10:37 pm

Autoloading In PHP

Autoloading In PHP :

 In real time scanario ,we create one php source file per class deffinition.
1.      One of the difficulty is having to write a long list of needed includes at the beginning of each script, one for each class.
2.      In php 5 you may define an __autoload() function which is automatically called in case you are trying to use a class which has not been defined yet.
<?php
function __autoload($class_name)
{
    echo "inside autoload function<br>";
    include_once ($c.".php");
}
$emp =new employee();
$cust = new customer();
$prod =new product();
$emp1 = new employee();

?>
<?php
class employee
{
   
}
?>
<?php
class product
{
   
}
?>
<?php
class customer
{
   
}
?>
In the above is __autoload() will be called 3 times.

Autoloading In PHP,php autoloading, autoload, autoload in php,php,php den

0 comments:

Post a Comment