PHP include () With reference delivery example _php tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.