note 83612 added to language.oop5.autoload
| From: | mohannadshubita at osu1 dot php dot net | Date: | Wed, 04 Jun 2008 14:06:40 +0000 |
| Subject: | note 83612 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140115@lists.php.net to get a copy of this message | ||
hi...i have this question :
i need to clear some points about the function __autoload :
IS THIS CORRECT :
in the beginning of the script we write :
function __autoload($class_name)
{
require($class_name.'.php');
}
then for ex :
$obj = new class1;
apache will first search for a defined class in the script with the name class1..if not found it
will load a file called class1.php in the same dir the script exists...
i add this :
function __autoload($class_name)
{
if(is_file($class_name.'.php'))
include it
else
echo "cant find file!";
}
then when i tried to create a new object :
$obj = new class1; and deleted the file class1.php it prints :
can find file
then fatal error :class 'class1' not found..
it is suppose to only print : cant find file
thanks
----
Server IP: 208.69.120.35
Probable Submitter: 213.6.235.252
----
Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/83612
Del: integrated -- https://master.php.net/note/delete/83612/integrated
Del: useless -- https://master.php.net/note/delete/83612/useless
Del: bad code -- https://master.php.net/note/delete/83612/bad+code
Del: spam -- https://master.php.net/note/delete/83612/spam
Del: non-english -- https://master.php.net/note/delete/83612/non-english
Del: in docs -- https://master.php.net/note/delete/83612/in+docs
Del: other reasons-- https://master.php.net/note/delete/83612
Reject -- https://master.php.net/note/reject/83612
Search -- https://master.php.net/manage/user-notes.php