Include is a function in PHP to call a file, by default it can not be directly like include (a.php?id=1) operation, let me introduce the solution include can not take parameters to call the solution.
Sometimes it is necessary to use the include () method in PHP to invoke a file with a separate service in the project, and if the called file uses get to pass in the data, some tips are needed.
Example: Suppose you need to call Inc.php?para=3 in index.php,
inc.php
The code is as follows |
Copy Code |
|
The following wording is not able to get the correct result:
index.php
The code is as follows |
Copy Code |
|
With a little flexibility, the $_get variable is defined before include, and it works fine:
index.php
The code is as follows |
Copy Code |
$_get[' para '] = 3; Include DirName (__file__). ' /inc.php;?> |
If the Allow_url_include feature is turned on in php.ini, you can use the Include URL:
index.php
The code is as follows |
Copy Code |
|
To set the method: PHP.ini, locate the following line and change to on:
The code is as follows |
Copy Code |
; Whether to allow Include/require to open URLs (like http:/or ftp://) as files. Allow_url_include = On |
However, to ensure security, most servers turn off the Allow_url_include feature, which can only be determined by the situation.
http://www.bkjia.com/PHPjc/632155.html www.bkjia.com true http://www.bkjia.com/PHPjc/632155.html techarticle include is a function of the call file in PHP, the default state is not directly like the include (a.php?id=1) operation, the following I will describe the solution include can not take parameters to call the solution ...