开发者

Is the php file extension needed for importation?

I wonder if I need to use ".php" for the php snippet files I must include in my principal page with include_once(...). When included in my code those snippets are handled as php instructions I guess so, then can we avoid the extension (snippets are in a folder named 'php' so no confusions).

Anyway isn't that going to make serious disturbance开发者_如何学运维s within my code ?


No, you don't need to use ".php" extension for "include_once()" or "include()". You may use any extension like may be .txt or .inc. The point to note that any PHP code in the included file is enclosed in the PHP tag, otherwise it will be treated as HTML.

Another point to consider is to not keep sensitive information in the included files (mainly if you choose to give them a non-.php extension) to prevent them being accessed on the browser. Or keep those files outside your document root.


If you remove the file extension from your include files and didn't setup your webserver accordingly, those includes can be viewed as regular text files as they're not interpreted by PHP (if the're within the web root)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜