- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我偶然发现了两个我以前从未在 php 中使用过的函数
set_include_path();
get_include_path();
我目前正在寻求将 phpseclib 实现到我正在开发的项目中。因为我需要使用 SSH2 的 SFTP 类扩展,而这又需要 MathBigInteger 类......等等。
手册中提到了set_include_path()
:
"Sets the include_path configuration option for the duration of the script. "
这对于我的框架的其余部分意味着什么?它会设置“phpseclib”目录中的所有包含路径吗?
另外,我真的不明白:
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
我将 php sec 存储在我的文件系统中的自定义库目录中,get_include_path() 是否能够神奇地找到我的文件系统中的 phpseclib 目录?
正如你所看到的,我完全迷失在这里......有人可以为我提供一些启发吗?
PS/我只在应用程序的一个特定点需要这个库,因此只想在需要时包含它,目前我想将它包含在我的模型类的子级中。
最佳答案
首先你需要了解 include_path
是什么?配置设置的作用是:
Specifies a list of directories where the require, include, fopen(), file(), readfile() and file_get_contents() functions look for files. The format is like the system's PATH environment variable: a list of directories separated with a colon in Unix or semicolon in Windows.
PHP considers each entry in the include path separately when looking for files to include. It will check the first path, and if it doesn't find it, check the next path, until it either locates the included file or returns with a warning or an error. You may modify or set your include path at runtime using set_include_path().
结构
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
将 phpseclib
附加到当您请求包含具有上述功能之一的文件时搜索的目录列表。
由于 phpseclib
是相对路径,因此效果与指定 ./phpseclib
相同,即 PHP 将查找名为 phpseclib 的子目录
在进程的当前目录内。它不会神奇地确定库在文件系统中的位置;您的工作是将其放在可以找到的地方。
关于php - set_include_path(get_include_path().PATH_SEPARATOR. 'phpseclib');,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14295164/
我偶然发现了两个我以前从未在 php 中使用过的函数 set_include_path(); get_include_path(); 我目前正在寻求将 phpseclib 实现到我正在开发的项目中。因
我是一名优秀的程序员,十分优秀!