search

Home  >  Q&A  >  body text

Concerned about how PHP identifies the paths ./ and / in Windows environment?

< /p>

< /p>

Why do you need to add . to have an effect?

< /p>

PHP中文网PHP中文网2788 days ago429

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:04:35

    / 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.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:04:35

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

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 13:04:35

    ./Start from the current directory

    / is calculated from the root directory

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 13:04:35

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

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

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

    reply
    0
  • Cancelreply