Differences and efficiency between include () and fopen () functions-php Tutorial

Source: Internet
Author: User
Differences between include () and fopen () functions and efficiency include () garbled fopen () functions

Q: differences and efficiency between include () and fopen () functions

If I want to reference a file, is it highly efficient to use include () or fopen ()? what is the difference, for example:

Test. php file

$ AB = "sfsadfsadfd ....";
....
?>

High-end files, AB. php

Include (test. php); or fopen (test. php) // Can you call the $ AB variable!
?>
Currently, the mainstream CMS uses INCLUDE or FOPEN to call files!

There is another problem, I use include () to introduce the file, the volume of the variable has Chinese he will be garbled, but I in the header to set the UTF-8, this problem occurs during PHP5.2 testing, but not in the latest PHP version.


Reply to discussion (solution)

Use include ();


You can save it as a social media code.

Does fopen have the same effect as include? I have to go to manual...

Include is an external program file that is integrated with the current program.
Fopen is used to open a file.

Each has its own role and cannot be confused.

I added htmlentities () for conversion and printed it as a code. the code is as follows:
$ Fieldvalue = implode ("','", $ fieldvalue). "', now (), now (),'". $ globalop. "'"; // value
// $ Fieldvalue = htmlentities ($ fieldvalue); garbled characters are generated when this parameter is added.
==================================

Is it enabled or introduced?

The two are different.

Good introduction, high efficiency

The include () and fopen () functions differently. include () introduces an external file, which can be an absolute or relative path. if a file is introduced by mistake, a prompt is displayed, and it contains the variable range that inherits the include row, but fopen () is to open a file, which can be an absolute or relative path, or a url request.

Include is a file, fopen is a file, not the same function

Include is an external program file that is integrated with the current program.
Fopen is to open a file ??

Can't I use the variables when I open them?

Variables cannot be directly used for fopen, and variables can be directly used for include.

Use a variable after opening. you can add an eval.
I don't know if the function definition is valid.
The two cannot be confused.

The two functions have different concepts.

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.