php learning (d) (document related)

File loading principle

  1. When the file is loaded (include or the require), the system will automatically contain the code to be embedded in the file corresponds to the current file
  2. Loaded position: include loading in which, in a position corresponding to the code file is embedded in a position corresponding to
  3. PHP files are contained separately compiled

PHP file during compilation If a syntax error occurs, it will fail (not execute); however, when if the file contains errors, the system will include the implementation to include this statement when the only error

PHP code execution flow

  1. Read the code files (PHP program)
  2. Compile: PHP converted to bytecode (generated opcode)
  3. zend engine to parse the opcode, according to a logic operation code byte
  4. Into corresponding HTML code

include and require difference

include and include_once difference:

include system will encounter once performed once; if the same file loaded more than once, the system will perform multiple

include_once: The system will encounter multiple times, it will only be loaded once

The difference between require and include the

Essentially contains the file, the only difference is that when the file contains less than, different forms of error

include a lesser level of error: the code will not stop running

Require a higher level of error: error code if it contains not execute (the latter require code)

File location

Files need to specify the path to the file at load time in order to ensure the correct PHP to find the corresponding file

Load path to the file contains two categories:

  1. Absolute path

    Start (local absolute path) from the root directory of the disk

    windows: the letter C: / path / php file

    Linux: / path / php file

    Start (absolute network path) from the root directory of the site

    /: The equivalent of a host name corresponding to the path network

  2. Relative path: The path starting from the directory where the current file

    . | ./: Indicates the current folder

    ../: parent directory (the current folder up one folder)

Load the difference between absolute and relative paths of

  1. Absolute path relative efficiency is low, but relatively safe (path no problem)
  2. Path relatively high efficiency, but prone to error (path go wrong)

Nested include files

Nested file comprising: a file contains another file, while the file contains a file also contains another

Nested included when it is prone to problems relative path error

Guess you like

Origin www.cnblogs.com/Joshua-Zhang/p/12198663.html
Recommended