Control script Execution Order
Die ( string )/exit ( string ):
After outputting the string, stop php execution immediately! That is, subsequent programs are no longer executed, including all other PHP and HTML code sections that follow.
Exit is synonymous with die. They can also stop without strings, but directly.
Sleep ($n)
Lets the program stop running for the specified number of seconds. Then wait for the time to run!
Note that the unit is " seconds ";
File loading
Summary and basic syntax:
1, there are 4 file loading statements:include, require, include_once, require_once
2, they are used exactly the same way, for example: include " file path to be loaded "; or: include (" file path to load ");
3, their meanings are almost exactly the same: they are different only when the load fails or if the load is repeated.
4, they can be loaded into PHP or html files;
File load path problem:
Prerequisites: The following illustration example, take include as an example, also applicable to the other 3 load statements;
There are 3 paths in the form that can be used:
Relative path:
is relative to the location of the current Web page file to locate a loaded file location, relying mainly on the following 2 special path symbols:
./ : Indicates the current location, that is, the location of the current Web page file (directory);
.. / : Indicates the previous position, that is, the location of the current Web page file in the upper level position (directory);
We need to use these 2 symbols to express position information, such as:
Include './page1.php '; // indicates the page1.php file where the current Web page file is located;
Include '. /page2.php ';
Include '. /ab/page3.html ';
Absolute path:
The absolute path is also divided into 2 kinds:
Local absolute path:
Like what:
Include "c:/d1/d2/p1.php";
Include "f:/f1/abc/p2.html";
Special note: We almost never should write this local absolute path directly in the code!
But, in fact, our local absolute path is very commonly used!
How do you do that? Examples are as follows:
1 Echo<p> load with relative paths;2 include'./page1.php '; 3 4 5 Echo"<p> using absolute Path Loading (Method 1)";6 include__dir__. ' \page1.php '; 7 8 9 Echo"<p> using absolute Path Loading (method 2)";Ten $root=$_server[' Document_root '];//get the following directory for the current site One include $root. "\day5". ' \page1.php ';
PHP Learning 3