I have some CONSTANTS, I want these constants to be available through every php file under a directory.

I put these constants file in this php

/home/public_html/constant/constant.php

And my php.ini file has these include_path value already,

.:/usr/local/lib/php:/usr/local/lib/php/PEAR

So I set up a .htaccess file under this directory, the .htaccess has my constant.php appending to the initial set up of include_path

.:/usr/local/lib/php:/usr/local/lib/php/PEAR:/home/public_html/constant:/home/public_html/constant/constant.php

or

.:/usr/local/lib/php:/usr/local/lib/php/PEAR:/home/public_html/constant:/home/public_html/constant

But none of them seems include my file /home/public_html/constant/constant.php

Thanks!

    That's because include_path doesn't automatically run PHP files, it just defines a set of paths to search for when opening a file (e.g. require_once).

    To achieve the former, look at using the auto_prepend_file PHP directive instead.

      It seems that auto_prepend_file cannot be used on multiple files.

      So the solution is that I can auto_prepend one file, and that file will require_once other files?

      Thanks!

        blackhorse;10968661 wrote:

        So the solution is that I can auto_prepend one file, and that file will require_once other files?

        It almost feels like a kludge, but that would indeed sound like the best solution if it's manageable.

        Don't forget to mark this thread resolved (if it is) using the link on the Thread Tools menu above.

          Write a Reply...