When everyone learns PHP, they think that the suffix of the php file must be .php. In fact, this is not the case. We can write it with other suffixes. This also prevents malicious attacks from others.
The suffix of PHP files is not forced to be .php
First, let’s test that the suffix of PHP files is according to the traditional .php file extension. File ending with php. Then run this file in your browser. Works perfectly.
We are creating a file. The suffix of this file is .inc. Then, run the file to see if it works. At this time, we will find a problem. When running, a download box will appear.
A file similar to this does not end with .php. But the content inside is php content. You have to use PHP's built-in function include or require to reference it for use.
Then run this file. As you can see, it works perfectly. Built-in PHP is that as long as it is PHP content, the PHP parser will run perfectly.
Notes
I used the a.php file and arr.inc for this test. This suffix can also be tel, etc.
For more PHP related knowledge, please visit the PHP Chinese websitePHP Tutorial!
The above is the detailed content of The php file suffix is not forced to be .php. For more information, please follow other related articles on the PHP Chinese website!