Home  >  Article  >  Backend Development  >  The php file suffix is ​​not forced to be .php

The php file suffix is ​​not forced to be .php

藏色散人
藏色散人Original
2019-09-17 17:16:372974browse

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 php file suffix is ​​not forced to be .php

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.

The php file suffix is ​​not forced to be .php

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.

The php file suffix is ​​not forced to be .php

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.

The php file suffix is ​​not forced to be .php

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.

The php file suffix is ​​not forced to be .php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn