“移动”是什么意思?一个文件到包含路径列表中?
在《Zend Framework,初学者指南》一书中;它说:
library/
目录的内容应该移动到 PHP 中的某个位置“include 路径”列表。
我不明白。不包括引用特定位置中特定目录的路径保留值。是这个意思吗?或者我是否必须将文件夹移动到“包含路径”中已经提到的位置?
In the book Zend Framework, a Beginner's guide; it says:
The contents of the library/
directory should be moved to a location in your PHP “include
path” list.
I don't get it. Doesn't include path hold values that reference a certain directory in a certain location. Is that what it means? or do I litterally have to move the folder to a place that is already mentioned in "include path"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PHP 的
include_path
与系统的 PATH 环境变量具有相同的用途:
正如 andre matos 之前的评论所指出的,您可以将库目录复制到系统的 PHP include_path 目录,也可以在 php.ini 文件中设置 PHP 路径配置指令“include_path”以将库目录包含为目录供 PHP 搜索。
无论您选择哪种方式,您都需要知道系统的 PHP include_path 目录。要查找系统的 PHP include_path 目录,您可以执行以下操作:
- 或者,创建一个文件,例如“phpinfo.php”,然后添加以下 php 代码:
并通过 PHP 运行该文件,
- 或者,添加该文件例如,“phpinfo.php”,到您的 Web 服务器知道的目录,然后在 Web 浏览器中将其作为 URL 打开并搜索“include_path”。
例如,我的系统的 PHP include_path 位于:
/usr/lib64/php
虽然最简单的方法可以说是将库目录复制到系统的 PHP include_path 目录(例如, /usr/lib64/php ),在系统的 php.ini 文件中设置 PHP 路径配置指令“include_path”也同样容易。
要在系统的 php.ini 文件中设置 PHP 路径配置指令“include_path”,请打开该文件并在“路径和目录”部分下找到“include_path”路径配置指令。它应该看起来像这样:
删除“;”来自操作系统的 PHP 'include_path' 路径配置指令。
例如,如果您使用的是 Linux,则应该如下所示:
然后将 PHP 'include_path' 路径配置指令设置为库目录,作为 PHP 搜索的目录。
例如,我将 ZendFramework 下载到
/usr/src/done/ZendFramework-1.11.4-minimal/
因此,我必须设置 PHP 'include_path' 配置指令以包含 ZendFramework 目录中的库目录,像这样:
系统 php.ini 文件中的“路径和目录”部分现在应该如下所示:
让我解释一下我添加到 php.ini 文件中的 PHP“include_path”配置指令中的目录(如上所示) :
这 '。'是当前目录,'/usr/lib64/php'是系统的PHP include_path目录,'/usr/src/done/ZendFramework-1.11.4-minimal/library'是库目录的路径ZendFramework 目录。请注意,PHP 'include_path' 配置指令中列出的每个目录必须用 ':' 分隔(与系统 PATH 环境变量中列出的目录相同)。
将目录列表添加到 php.ini 文件中的 PHP“include_path”配置指令后,必须重新启动 Web 服务器以保存对 PHP 的更改。
例如,
% sudo apachectl restart # 假设您正在使用Apache 作为您的 Web 服务器
希望这会有所帮助,
// Elliot。
PHP's
include_path
serves the same purpose as the system's PATH environment variable:As the previous comment by andre matos indicated, you can either copy the library directory to your system's PHP include_path directory or you can set the PHP path configuration directive, 'include_path', in your php.ini file to include the library directory as a directory for PHP to search through.
Regardless of which way you choose, you need to know your system's PHP include_path directory. To find your system's PHP include_path directory, you can either do:
-or, create a file, e.g., 'phpinfo.php', and add the following php code:
and run the file through PHP,
-or, alternatively, add the file e.g., 'phpinfo.php', to a directory your web server knows about, and open it as a url in a web browser and search for 'include_path.'
For example, my system's PHP include_path is at:
/usr/lib64/php
Although the easiest way is arguably to just copy the library directory to your system's PHP include_path directory (e.g., /usr/lib64/php), it is also equivalently easy to set the PHP path configuration directive 'include_path' in your system's php.ini file.
To set the PHP path configuration directive 'include_path' in your system's php.ini file, open the file and locate the 'include_path' path configuration directive under the 'Paths and Directories' section. It should look something like this:
Remove the ';' from the PHP 'include_path' path configuration directive for your operating system.
e.g., If you are on Linux, it should look like this:
Then set the PHP 'include_path' path configuration directive to the library directory, as a directory for PHP to search through.
e.g., I downloaded the ZendFramework to
/usr/src/done/ZendFramework-1.11.4-minimal/
Therefore, I must set the PHP 'include_path' configuration directive to include the library directory within the ZendFramework directory, like this:
The 'Paths and Directories' section in the system's php.ini file, should now look like this:
Let me explain the directories I added to the PHP 'include_path' configuration directive in the php.ini file (shown above):
The '.' is the current directory, the '/usr/lib64/php' is the system's PHP include_path directory, and the '/usr/src/done/ZendFramework-1.11.4-minimal/library' is the path to the library directory in the ZendFramework directory. Note that each directory listed in the PHP 'include_path' configuration directive must be separated by a ':' (same as the directories listed in the system's PATH environment variable).
After you have added your list of directories to the PHP 'include_path" configuration directive in the php.ini file, you must restart your web server to save the changes to PHP.
e.g.,
% sudo apachectl restart # assumes you are using Apache as your web server
Hope this helps,
//. Elliot
嗯...你可以两者都做。
将包含路径添加到您的
php.ini
(搜索类似include_path
的内容)或将文件夹移动到已包含的某个路径(在执行前面的操作后您将知道哪些路径)搜索
php.ini
)。当您执行以下操作时:
如果文件与您正在执行的脚本不在同一目录 (.) 中,则 php 将在 php.ini 上定义的包含路径中查找。
Well... You can do both.
Add an include path to your
php.ini
(search for something likeinclude_path
)Or move the folder to some path already included (that you will know which are after performing the previous search on
php.ini
).When you do something like:
If the file is not in the same directory (.) as the script you're executing php will look in the include paths defined on php.ini.