Php reads the source code output of the local php file.

Source: Internet
Author: User
Next, let's take a look at the code that uses fopen, file_get_contents to read the php file on the local server and some methods that are displayed. for example, if I have two files: aphp, bphp, and aphp, the statement in the file is: now, I need to display the file in the bphp file.

Next, let's take a look at a summary of some methods that use fopen, file_get_contents to read the. php file code on the local server and display it.

If I have two files, a. php, B. php, and a. php, the statements in the file are:

Echo "I am a. php";?>

Now, I need to display the source code in file a. php in the B. php file. the source code is as follows:

$ A_code = file_get_contents ('A. php'); echo htmlspecialchars ($ a_code); // www.phpfensi.com?>

The focus is on the htmlspecialchars () function. the htmlspecialchars () function converts some predefined characters into HTML objects.

Let's look at the fopen () function of the instance. the code is as follows:

$ File = fopen ("a. php", "r ");

The effect is the same as above. of course, if we only want to display B. php in a. php, we can directly use inlucde () to call it. the code is as follows:

Inlucde ('A. php ');

If you want to read the. php file of the remote server, the html content is returned. do not ask why. otherwise, no program is written.

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.