Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Dimitri Vorontzov

Extensions Of The Included Files

Recommended Posts

I'm back to "Book 1" ("Repetition is the mother of knowledge") -

 

- and I have a question.

 

When I separate recurrent parts of the web application into separate files, to be included in the index.php, is it possible to use file extensions for included files other than .html, or .inc.html, or .php?

 

For example, what if I want to save my header and footer as header.txt and footer.txt, or even header.jpg and footer.jpg. Would the code contained in them still work if I include them with modified extensions?

 

Is this, or something similar, ever done, for example, as a security trick?

 

Would appreciate your help!

Share this post


Link to post
Share on other sites

You can use any file extension you want for included files and it won't impact the usability of them as included files. However, if your included files has PHP in them, then you're making your site LESS secure by not using an extension that ends in .php. If you use .txt, for example, then the raw PHP code would be viewable in a browser.

  • Upvote 1

Share this post


Link to post
Share on other sites

You're quite welcome. Personally, I wouldn't mess with file extensions too much, or rely upon them for security measures. File extensions are also supposed to convey meaning, which you lose when you swap them around for security purposes. Also, the use of .php extension to make something unviewable in a browser only applies if there's code within PHP tags. If you put plain text in a .php file and don't use the PHP tags, it'll still show. The best way to prevent something from being viewable in a web browser is to not put it in the Web directory. If that's not possible, the second best option is to use an .htacess file to deny access.

  • Upvote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...