Search code examples
phpconfigurationinclude-path

include PHPWhoIs by default for all scripts


So I have PHPWhoIs located in plugins/phpwhois-4.2.2 of the root of my server.

I'm able to use the Whois() class in php scripts by including it like:

include_once('../../../plugins/phpwhois-4.2.2/whois.main.php');

$whois = new Whois();

But I'm trying to make my server include this file by default. I've tried adding this to my php.ini

include_path=".:/plugins/phpwhois-4.2.2/whois.main.php"

And confirmed it took with var_dump(ini_get('include_path'));, but then it says the class Whois() doesn't exist.

I also notice I'm overwriting the default include_path.

How can I add this path to be included so it will work by default in any script?


Solution

  • Include path is used to tell PHP where to look when you use an include in your code, so it's a list of directories... it doesn't automatically do the includes for you

    So with

    include_path=".:/plugins/phpwhois-4.2.2
    

    in your php.ini, then

    include "whois.main.php" 
    

    will successfully find the file to include

    You might look at the auto_prepend_file ini setting though to include a specific php file before the main body of your script