Search for PHP-class Linux path
I don't want to ask special classes, just the basics, what is the basic principle of the PHP search class, For example, I quoted a Test2 class in test1.php, the declaration of this class in test2.php, then how will PHP find this class, I put test2.php in the current directory, but also hint that the error did not find the class AH. Get_include_path () also has this path. Need to go to config file to do something? I am under the Linux, did not find the online php.ini brother just contact PHP, which elder brother can explain here?
Reply to discussion (solution)
Include (' test2.php ');
...
?>
If you do not explicitly tell PHP where to look, then PHP will not do invalid labor (because the search through the entire hard disk may not be found)
1, you can explicitly include, Require loading class definition files
2. You can define a __autoload function that will be called automatically when you try to use a class that is not already defined. By calling this function, the scripting engine has the last chance to load the required classes before PHP fails.
3. You can also use the SPL_XXX function group to load your class