Home > Article > Backend Development > Why can’t PHP class file suffix be .php?
<code>include 'PhpBeautifier.inc';//为什么这个class 是.inc 结尾呢? $beautify = new PhpBeautifier(); $beautify -> tokenSpace = true;//put space between tokens $beautify -> blockLine = true;//put empty lines between blocks of code (if, while etc) $beautify -> optimize = true;//optimize strings (for now), if a double quoted string does not contain variables of special carachters transform it to a single quoted string to save parsing time $beautify -> file( 'test.php', 'beautified.php' ); </p> <p>?></p> <p>https://github.com/easychen/L...</p> <h2>Reply content:</h2> <p><?php</p> <pre class="brush:php;toolbar:false"><code>include 'PhpBeautifier.inc';//为什么这个class 是.inc 结尾呢? $beautify = new PhpBeautifier(); $beautify -> tokenSpace = true;//put space between tokens $beautify -> blockLine = true;//put empty lines between blocks of code (if, while etc) $beautify -> optimize = true;//optimize strings (for now), if a double quoted string does not contain variables of special carachters transform it to a single quoted string to save parsing time $beautify -> file( 'test.php', 'beautified.php' ); </p> <p>?></p> <p>https://github.com/easychen/L...</p> <p class="answer fmt" data-id="1020000006160004"> </p> <p>Because it just marks a file, you can change the suffix to any legal character (even if you remove the suffix). <br>PHP’s internal execution process is roughly like this: </p> <ol> <li><p>Find the file corresponding to the file name or path; </p></li> <li><p>Read the contents of the file; </p></li> <li><p>Parse the content into PHP code and execute it. </p></li> </ol> <p>So, this has nothing to do with what the suffix is. The suffix here is just to identify the function of this file. Similar ones include XXX.tpl (template), etc. </p> <p class="answer fmt" data-id="1020000006160000"> </p> <p>include can include any type of file, as long as you have permission to read it, such as the following</p> <pre class="brush:php;toolbar:false"><code><?php include "../.gitignore";</code>
Well, thank you for the invitation. The previous answers are all correct, so pay attention to the security of include/require.
Thanks for the invitation. I was stunned for a moment when I saw this question. The include directive is used to import and run the specified file (same as require).
require
include
Any type of text file can be used. The content in the referenced file will be executed as php code (only if
You can require/include a txt, html, js, css, etc. Some PHP Trojans use this to bypass the detection of security tools.