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.