Search code examples
phpxamppinclude-path

Including files from include path not working as expected


When I run this code in a php file:

get_include_path();

I get this result:

.:/Applications/XAMPP/xamppfiles/lib/php:/Applications/XAMPP/xamppfiles/lib/php/pear

So shouldn't all files from either of these 2 directories be automatically included in all my php files? Because when I put a file with a class in 1 of them and try using it in my php file, it says

Fatal error: Class 'FirePHP' not found in /Applications/XAMPP/xamppfiles/htdocs/index.php on line 4


Solution

  • You misunderstood the include_path. It won't include automatically all the files in there.

    The include_path is a list of paths from where you can include with an relative path.

    So, if you write include 'FirePHP.php'; then the file, if it exists in one of these paths, . (this directory), /Applications/XAMPP/xamppfiles/lib/php or /Applications/XAMPP/xamppfiles/lib/php/pear, will be included.