Include () in php with reference to transfer instance _ PHP Tutorial

Source: Internet
Author: User
Include () in php carries a reference transfer instance. Include is a function that calls files in php. by default, it cannot be like include (a. php? Id1) in this way, the following describes how to solve the problem that include does not include a parameter call solution. include is a function in php that calls a file. by default, it cannot be like include (. php? Id = 1) in this case, the following describes how to solve the problem of using include without parameters.

Sometimes, based on some special requirements, you need to use the include () method in PHP to call a file that independently provides services in the project. If the called file uses the GET method to import data, you need some tips.

For example, suppose that inc. php needs to be called in index. php? Para = 3,

Inc. php

The code is as follows:

The following statement cannot produce the correct result:
Index. php

The code is as follows:


With a slight flexibility, you can define the $ _ GET variable before include to run normally:
Index. php

The code is as follows:
$ _ GET ['para'] = 3;
Include dirname (_ FILE _). '/inc. php;?>

If the allow_url_include function is enabled in php. ini, you can use the include url method:
Index. php

The code is as follows:


Setting method: in php. ini, find the following line and change it to On:

The code is as follows:

; Whether to allow include/require to open URLs (like http: // or ftp: //) as files.
Allow_url_include = On

However, to ensure security, most servers disable the allow_url_include function.

Compile (a. php? Id = 1) in this case, the following describes how to solve the problem that include cannot contain parameters to call...

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.