简体   繁体   English

PHP __DIR__显示系统根目录

[英]PHP __DIR__ displays system root

today i got some confuseing error my __DIR__ is pointing to the System root directory, but i need the Apache2 root-dir 今天我遇到一些令人困惑的错误,我的__DIR__指向系统根目录,但是我需要Apache2根目录

i tried to add 我试图添加

php_admin_value open_basedir /var/www/html

in apache2.conf and sites-aviable/000-default.conf 在apache2.conf和sites-aviable / 000-default.conf中

is there any option in php.ini? php.ini中有任何选项吗?

i am using 我在用
PHP: PHP:

PHP 5.5.9-1ubuntu4.3


Apache: 阿帕奇:

Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jul 22 2014 14:36:38


In my case 就我而言

__DIR__ == "/var/www/html/"

May you can help me 可以帮我吗

There's no real way to do that. 没有真正的方法可以做到这一点。 __DIR__ is an absolute path to the current file. __DIR__是当前文件的绝对路径。 There are many reasons you need to know this and it cannot be changed. 有很多原因需要了解,并且无法更改。

open_basedir is a directive to restrict what files PHP and Apache have access to in a given site. open_basedir是一个指令,用于限制PHP和Apache在给定站点中可以访问的文件。 It's most commonly used in shared hosting environments to keep user A from accessing user B's files. 它最常用于共享主机环境中,以防止用户A访问用户B的文件。

__DIR__是此代码所在文件的路径。因此,如果您的脚本位于根目录中,则__DIR__可以按您希望的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM