Using relative paths to access files is to access files by directory starting from the "current directory". A relative path is a path starting from the current path and refers to the path relationship with other files (or folders) caused by the path where this file is located.
Absolute path and relative path
Absolute path:
is the path starting from the drive letter, in the form of
C:\windows\system32\cmd.exe
Relative path:
is the path starting from the current path, if the current path is C:\windows
To describe the above path, just enter
system32\cmd.exe
In fact, the strict relative path writing should be .\system32\cmd.exe
Among them, .
represents the current path, which can be omitted in the case of channels, but cannot be omitted only in special circumstances.
If the current path is c:\program files
To call the above command, you need to enter
..\windows\system32\cmd.exe
where, ..
is the parent directory.
If the current path is c:\program files\common files
, you need to enter
..\..\windows\system32\cmd.exe
In addition, there is also a path that does not include a drive letter Special absolute path, in the form of
\windows\system32\cmd.exe
No matter what the current path is, it will automatically search for the specified program starting from the root directory of the current disk.
For more related knowledge, please visit: PHP Chinese website!
The above is the detailed content of Accessing files using relative paths starts with accessing files by directory?. For more information, please follow other related articles on the PHP Chinese website!