Include () and fopen () function difference and efficiency

Source: Internet
Author: User
Tags variable scope
Include () garbled fopen () function

Ask you heroes: include () and fopen () function difference and efficiency

If I want to refer to a file, is the use of include () high efficiency or with fopen () high efficiency, his difference is what, for example:

test.php file

$ab = "SFSADFSADFD ...";
....
?>

High-use files, ab.php

Include (test.php); or fopen (test.php)//Can call $AB variable!
?>
Now the mainstream CMS his call file is to use include or fopen it!

There is another problem, I use the include () to introduce file parts, the amount of variables have Chinese he will be garbled, but I in the head to set up a UTF-8, in the PHP5.2 test will appear this situation, but in the latest version of PHP does not appear in this situation


Reply to discussion (solution)

use include ();


You save as, look at the social code.

Fopen like the include effect? I have to go to see manual.

Include is the introduction of an external program file that is in harmony with the current program
Fopen is to open a file

Each has a role, can not confuse

Garbled problem, I added the htmlentities () conversion, and then print out is into code, the code is as follows
$fieldvalue = Implode ("', '", $fieldvalue). "', now (), now (), '". $globalop. "'"; /value
$fieldvalue = Htmlentities ($fieldvalue); Add this will be garbled
=============================

Is that open, or is it good to be introduced?

The two are different.

Good introduction, high efficiency

The include () and fopen () functions are not the same, include () is to introduce an external file, can be an absolute or relative path, the introduction of a file error occurs when prompted, and it contains the row that inherits the include variable scope, but fopen () is to open a file, can be an absolute or relative path, or it can be a request in the form of a URL.

Include is an include file, fopen is an open file, not the same feature

Include is the introduction of an external program file that is in harmony with the current program
fopen is open a file??

Can't you use the variables in the open?

Fopen cannot use variables directly, include can use variables directly

To use a variable after open, you can add another eval.
If the function definition is valid, you do not know.
The two cannot be confused.

The concept of 2 functions is different

  • 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.