使用"auto_prepend_file";进入".user.ini" PHP中的文件 [英] Using "auto_prepend_file" into ".user.ini" file in PHP

查看:284
本文介绍了使用"auto_prepend_file";进入".user.ini" PHP中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在项目的任何页面的运行时加载文件variables.php(仅包含变量),以便可以在任何地方使用变量.

I want to load the file variables.php (that simply contains variables) at the run of any pages of my project so I can use the variables from any place.

我创建了一个名为.user.ini的文件(并将其放置在根文件夹中):

I created a file called .user.ini (and placed it in the root folder):

; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = /Volumes/www/project_name/admin/libs/variables.php

它不起作用.似乎PHP无法读取.user.ini文件.

It doesn't work. It seems that PHP doesn't read the .user.ini file.

php.ini默认情况下配置正确:

php.ini is right configured by default:

user_ini.cache_ttl    300           300
user_ini.filename     .user.ini     .user.ini

我在哪里错了?

推荐答案

好吧,

自PHP 5.3.0起,PHP包含了对在Windows上配置INI文件的支持. 每个目录的基础. 这些文件仅由CGI/FastCGI处理 SAPI .此功能使PECL htscanner扩展无效.

Since PHP 5.3.0, PHP includes support for configuration INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension.

并且:

如果您使用的是Apache,请使用.htaccess文件以达到相同的效果.

If you are using Apache, use .htaccess files for the same effect.

...尽管它实际上是指Apache 模块.

... though it actually refers to the Apache module.

如果您需要独立于SAPI的自定义设置,恐怕您将必须同时使用 .如果将这些设置保持在最低水平,则可以最大程度地减少维护负担(大多数PHP指令可以在PHP代码本身中提供).并且您需要确保当mod_php不可用时,.htaccess设置不会崩溃:

If you need SAPI-independent custom settings I'm afraid you'll have to use both. You can minimise the maintenance burden if you keep those settings to the minimum (most PHP directives can be provided in PHP code itself). And you need to ensure that .htaccess settings don't crash when mod_php is not available:

<IfModule mod_php5.c>
    php_value auto_prepend_file /Volumes/www/project_name/admin/libs/variables.php
</IfModule>

这篇关于使用"auto_prepend_file";进入".user.ini" PHP中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆