zoukankan      html  css  js  c++  java
  • PHP 配置指令 include_path 详解

    php.ini中有个指令,include_path 包含路径,指定一系列路径列表,用于下面函数寻找文件,如
    require,include,fopen(),file(),readfile() and file_get_contents().

    格式类似于系统环境变量,PATH,Unix用冒号(colon)分隔,Windows用分号(semicolon)分隔;

    PHP会按路径顺序分别寻找被包含文件,先找第一个,找不到再找第二个,直到找到对应文件,或者所有路径都找不到则返回一个warningerror

    除了可以在配置文件中指定外,还可以在运行时用 set_include_path()ini_set 修改。

    PHP的默认值是 .;/path/to/php/pear.

    示例一

    include_path=".:/php/includes" //Unix
    include_path=".;c:phpincludes" //Windows
    

    使用 . 允许指定相对路径,代表当前目录。不过,明确使用 include './file' 会比让PHP逐个检测当前路径更高效。

    示例二

    include_path = ".:${USER}/pear/php"
    

    环境变量在.ini文件中也是可以使用的,可以使用${LOGIN} and ${USER} 定位到主目录。

    环境变量可能会根据所使用服务器API的不同而不同。

  • 相关阅读:
    优化tomcat——jvm
    深入理解jvm
    Too many open files
    Ubuntu 18.04 chrome安装
    Ubuntu 对比度调节
    SSH 开启,安装
    Ubuntu的Gnome美化
    snap占用/dev/loop0-/dev/loop11占用100%
    C题——Halting Problem(补题)
    H:有趣的试剂(1317)
  • 原文地址:https://www.cnblogs.com/jiaoran/p/12820034.html
Copyright © 2011-2022 走看看