In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the use of include in php, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The function of include in php is to include and run the specified file, the included file first looks for the path given by the parameter, and if no directory is given, it looks for the directory specified by include_path, such as "include 'vars.php';".
This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer.
Include (PHP 4, PHP 5, PHP 7, PHP 8)
The include expression contains and runs the specified file.
The following documents also apply to require.
The included file first looks for the path given by the parameter, and if no directory is given (only the file name), it looks for the directory specified by include_path. If the file is not found under include_path, include finally looks for it in the directory where the calling script file is located and the current working directory. If the file is not found in the end, the include structure issues an E_WARNING; unlike require, which emits an E_ERROR.
Note that if the file is unreachable, include and require both issue an additional E_WARNING before issuing the final E_WARNING or E_ERROR, respectively.
If a path is defined-whether it is an absolute path (starting with a drive letter or\ under Windows and / under Unix/Linux) or a relative path to the current directory (with. Or... At the beginning)-include_path will be completely ignored. For example, if a file starts with.. /, the parser will look for the file in the parent directory of the current directory.
For more information on how PHP handles include files and include paths, see the documentation in the include_path section.
When a file is included, the code it contains inherits the range of variables on the line where include resides. From there, any variables available to the calling file at this line are also available in the called file. However, all functions and classes defined in the include file have global scope.
Example # 1 basic include example
Vars.php
Test.php
If include appears in a function in the calling file, all the code contained in the called file will behave as if they were defined within the function. So it will follow the variable range of the function. One exception to this rule is magic constants, which are processed by the parser before inclusion occurs.
Example # 2 contains the function
When a file is included, the syntax parser leaves PHP mode at the beginning of the target file, enters HTML mode, and recovers at the end of the file. For this reason, any code in the object file that needs to be executed as PHP code must be included in valid PHP start and end tags.
If "URL include wrappers" is activated in PHP, you can use URL (through HTTP or other supported wrapper protocols-see supported protocols and wrapper protocols) rather than local files to specify the files to be included. If the target server interprets the target file as PHP code, the URL request string for HTTP GET can be used to pass variables to the included file. Strictly speaking, this is not the same thing as the variable space that contains a file and inherits the parent file; the script file is actually running on the remote server, and the local script includes its results.
Example # 3 include via HTTP
Warning
Remote files may be processed by the remote server (depending on the file suffix and whether the remote server is running PHP or not), but a legitimate PHP script must be generated because it will be processed by the local server. If the files from the remote server should be run remotely and only output the results, it is better to use the readfile () function. Also be careful to ensure that remote scripts generate legal and required code.
Thank you for reading this article carefully. I hope the article "what is the use of include in php" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.