Hi

I don’t have access to my php.ini file as I’m using a shared hosted environment. I am aware that you can use the 'set_include_path' function however I’m unsure how this function behaves.

Consider the following:

set_include_path('mylibrary/');

This sets the path to 'mylibrary/' from the root of your web directory. This works fine and you can include files as normal. However when you try and include files from a file one directory level down you receive a fatal error as the file can't be found.

For example, files one directory level down require the include path to be set to '../mylibrary/' but this obviously would break include requests from files within a directory at a different level.

Does anyone know why this would happen? Am I doing something wrong or this a server specific issue?

Thanks

Jon.

    Hi,

    set the full path to the include directory (/the/full/path/to/mylibrary or e.g. $_SERVER['DOCUMENT_ROOT'].'/mylibrary'). That should solve the problems. Just setting mylibrary will make PHP to search for include files in mylibrary relative to the current path.

    The possible problem with using $_SERVER['DOCUMENT_ROOT'] is that this variable isn't always set (depending on the platform and the setup of php).

    Thomas

      Write a Reply...