PHP auto include

后端 未结 3 1315
情书的邮戳
情书的邮戳 2021-01-17 19:32

I want to auto include a PHP script onto every exection into the server, I was hopping to do it via the PHP ini, via a setting or being able to write an extention in php tha

3条回答
  •  梦谈多话
    2021-01-17 19:47

    Another solution, if you're on Apache and this is available to you, is to use .htaccess. I add a line:

    php_value include_path "/var/www/mysite.com/config"

    and then in my PHP files, I can include

    include_once('someconfig.php');

    which looks in /var/www/mysite.com/config/. Admittedly, I've done this without knowing the auto-prepend solution--which looks much cleaner and more efficient.

提交回复
热议问题