As shown in the picture:
The connection of a single page under many files. When referencing files, you need to have a certain understanding of the path issue; or programmers who have knowledge of PHP network program development will define There are many insights into defining variable paths and references in combination with include.
For example:
define ('ROOT_PATH',dirname(__FILE__));
include(ROOT_PATH."/inc/webconfig.php");
include(ROOT_PATH."/inc/sysinfo.php");
include( ROOT_PATH."/inc/functions.php");
include(ROOT_PATH."/inc/db_sql.php");
These are what I will analyze next.
Main content: •The concepts of relative paths and absolute paths
•Detailed analysis
The concepts of relative paths and absolute paths
This is what the operating system class said, when it comes to file search, absolute path: In a tree directory structure, there is only one unique path from the root node to a data file or directory file. Connect the directory file names and data file names passing from the root node to a data file with "/" to form a path name that can be used to access the data file; relative path: you can set one for each process "Current directory", also known as "working directory", so that every time you find a file, you don't need to use an absolute path mechanically. Instead, use the path of the file relative to the current directory. This is a relative path. Of course, it is a bit abstract. Please see below for details. My analysis is mainly used in html. Correctly reference a file. For example, how to reference another HTML web page as a hyperlink in an HTML web page? How to insert an image into a web page?
If you use the wrong file path when referencing a file (such as adding a hyperlink, or inserting a picture, etc.), the reference will become invalid (the linked file cannot be browsed, or the inserted picture cannot be displayed, etc.) .
In order to avoid these errors and reference files correctly, we need to learn HTML paths.
HTML has two ways of writing paths: relative paths and absolute paths.
HTML relative path (Relative Path)
File reference in the same directory
If the source file and the reference file are in the same directory, directly Just write the reference file name.
We now create a source file info.html, and reference the index.html file as a hyperlink in info.html.
Assume the info.html path is: c:Inetpubwwwrootsitesblablainfo.html Assume the index.html path is: c:Inetpubwwwrootsitesblablaindex.html The code to add the index.html hyperlink to info.html should be written like this:
index.html How to represent the upper-level directory
../ represents the upper-level directory of the directory where the source file is located, http://www.jb51. net/ represents the directory above the directory where the source file is located, and so on.
Assume the info.html path is: c:Inetpubwwwrootsitesblablainfo.html Assume the index.html path is: c:Inetpubwwwrootsitesindex.html The code to add the index.html hyperlink to info.html should be written like this:
index.html Assume the info.html path is: c:Inetpubwwwrootsitesblablainfo.html Assume the index.html path is: c:Inetpubwwwrootindex.html in info The code to add a hyperlink to index.html in .html should be written like this:
index.htmlAssumption The info.html path is: c:Inetpubwwwrootsitesblablainfo.html Assume the index.html path is: c:Inetpubwwwrootsiteswowstoryindex.html The code to add the index.html hyperlink to info.html should be written like this:
index.html How to represent the lower-level directory
To reference files in the lower-level directory, just write the path of the file in the lower-level directory directly.
Assume the info.html path is: c:Inetpubwwwrootsitesblablainfo.html Assume the index.html path is: c:Inetpubwwwrootsitesblablahtmlindex.html The code to add the index.html hyperlink to info.html should be written like this:
index.html Assume the info.html path is: c:Inetpubwwwrootsitesblablainfo.html Assume the index.html path is: c: Inetpubwwwrootsitesblablahtmltutorialsindex.html The code to add the index.html hyperlink to info.html should be written like this:
index.htmlHTML is absolutely Path (Absolute Path)
HTML absolute path (absolute path) refers to the complete path of the file with domain name.
Suppose you register the domain name www.jb51.net and apply for a virtual host. Your virtual host provider will give you a directory, such as www. This www is the root directory of your website.
Suppose you place a file index.html in the www root directory. The absolute path of this file is: http://www.jb51.net/index.html.
Suppose you create a directory called html_tutorials in the www root directory, and then place a file index.html in the directory. The absolute path of this file is http://www.jb51.net/html_tutorials/ index.html.
Some information reference:
The difference between relative paths and absolute paths