
1 batnss 2016-12-29 13:17:40 +08:00 get_include_path() 看看 |
3 ncwgf 2016-12-29 13:30:28 +08:00 忘了哪始 我都成 `include implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'test.php'));` 因要假控制不了境 短一 `include implode(DIRECTORY_SEPARATOR, [__DIR__, 'test.php']);` 在不知何能找到 何找不到 |
4 skydiver 2016-12-29 13:38:55 +08:00 不应该是 ./test.php 吗…… |
5 harborM 2016-12-29 13:40:00 +08:00 实在不行就用绝对路径呗 |
7 iscraft OP |
8 msg7086 2016-12-29 13:48:03 +08:00 / 指向的是文件系统根目录吧? |
9 iscraft OP @msg7086 但 5.4 和 5.6 都会在 index.php 所在的 E:\desktop\www 下找到 test.php 唯独 7 会报出错误 |
10 Scholer 2016-12-29 13:56:14 +08:00 nginx 里 root 配的不一致吧 |
11 iscraft OP @Scholer 使用的是 windows 下的 apache FreeBSD 中 Caddy+php7 下加 /报错 不加正常执行 个人感觉跟 web server 关系不大 与 php 版本有关 |
13 yaxin 2016-12-29 14:14:23 +08:00 把 php-fpm 开成一个,然后 strace -p fpm 子进程 id ,看一下到底加载的那个文件 |
14 iscraft OP @skydiver 后面会避免这种错误写法 只是想看看官方或者一些正式的说法 毕竟这情况至少在 5.2.10 就出现了 |
15 wesley 2016-12-29 15:02:41 +08:00 这也怪 php ? 先搞清楚 URL 路径和文件系统路劲 |
16 greatonce 2016-12-29 15:14:59 +08:00 ubuntu nginx php-7.0.13 下面没有问题 |
17 iscraft OP @wesley 才疏学浅 不敢怪 一点小疑问 还请不吝赐教 /是作为 url 路径表示网站根目录而不能作为文件系统路径表示 DocumentRoot 的 那么 为什么 5+可以依据这个符号包含进来文件 而 7 不可以? 求相关的官方或者非官方文档解释都可以 谢谢 |
19 Felldeadbird 2016-12-29 15:38:22 +08:00 你想 /test.php 指向当前 运行目录的根目录,那么你就的让 apache 、 nginx 、 PHP 添加对应的配置信息。 具体配置你可以网上找一下。 一般来说,这种写法有很大问题,因为太过依赖配置的信息,一旦换了一个人或者一个服务器新的配置,那么你的程序就黄了。 |
20 greatonce 2016-12-29 15:39:25 +08:00 @iscraft ... 吓我一跳,你以为搞前端呢,/ 在 php 服务器端表示服务器上的根目录, 网页上你可以用 / 访问网站目录下的资源,服务端不可以。 |
21 iscraft OP @Felldeadbird 写法是不对 但在 windows 的同一个 apache2.4.7 下分别加载了 5.2/5.4/5.6/7.0.12 针对 /符号 7 出现了错误 就想搞明白这个是为啥 |
22 greatonce 2016-12-29 15:50:37 +08:00 @iscraft Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include will finally check in the calling script's own directory and the current working directory before failing. The include construct will emit a warning if it cannot find a file; this is different behavior from require, which will emit a fatal error. http://php.net/manual/zh/ini.core.php#ini.include-path |
23 greatonce 2016-12-29 15:52:27 +08:00 @iscraft 因为你的 include_path 配置 指定了当前目录可以被当做搜索目录, php7 的配置可能没有这个而已 你可以看看 几个不同版本的 php.ini 里面的 include_path 选项。 |
25 greatonce 2016-12-29 17:34:36 +08:00 |
26 lslqtz 2016-12-29 17:38:42 +08:00 使用相对路径不好吗? |
27 royantar 2016-12-29 17:51:09 +08:00 7.0 版本将 Windows 环境下这样的路径视为绝对路径: #if PHP_WIN32 /* This should count as an absolute local path as well, however IS_ABSOLUTE_PATH doesn't care about this path form till now. It might be a big thing to extend, thus just a local handling for now. */ filename_length >=2 && IS_SLASH(filename[0]) && !IS_SLASH(filename[1]) || #endif |