关于windows环境下,php对路径./和/的识别疑惑?
PHP中文网
PHP中文网 2017-05-16 13:02:35
0
4
407

为什么要加.才会有作用?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
伊谢尔伦

/ is the root directory. Using is_dir() in php to judge always returns false
, but it is possible to read this directory, such as:

$dir=opendir("/");
while(($tem=readdir($dir))!==false){
  echo $tem,"<br>";
}

Can read the root directory of all hard disks.

In ThinkPHP 3.2, the single entry file: index.php is placed in the root directory of the website. This root directory is not the same as the hard disk root directory mentioned earlier.

Because it is a single entry, the "./" current directory in the controller is actually relative to index.php.

曾经蜡笔没有小新

./ self
../ parent
/ root directory
That’s how I remember

大家讲道理

./Start from the current directory

/ is calculated from the root directory

習慣沉默
  • /代表根目录 ,比如目录结构 /var/www/html,当前目录是 html下,那么输入 命令 cd /,当前目录切换到 根目录.

  • ./ 代表当前目录,当前处于 html 下,输入 cd ./, the current directory remains unchanged.

  • ../ 代表父级目录,当前处于 html 下,输入 cd ../,切换后的目录为 /var/www.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!