completeamateur Posted April 3, 2006 Share Posted April 3, 2006 Just a couple of q's regarding include files...1. Can I give them any extension I want? What is the best (.php .inc .txt)?2. Does it matter if I have loads of includes in one page. I plan to have a template with 7 different include files (albeit small) to make maintenance/content easier to manage.Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 3, 2006 Share Posted April 3, 2006 it doesn'y matter what extension you give anyfile in an include statement.But bear in mind the file is treated as plain text so if you want to include more php code the included file must be a valid stand alone script (it must have the <?php and ?> tags in there.)You can include as many things as you like - but have a look at using include_once and the require equivalents also they can really help especially in big files when you are not sure what you have or have not included yet.Be sure to refrain from having paths to includes being generated from user input. If it is absolutely neccessary use $_SERVER['DOCUMENT_ROOT'] at the start of the path - this will prevent them from including files on another server which could easily breach your own security. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 4, 2006 Share Posted April 4, 2006 You can use any extension you like but allweasy save your files that get included with .php extensions otherise any other file such as .html, .txt, .inc will treat your PHP code as normal text and so a user can see your PHP Code! However you can use any extension you like for your files that get included as PHP will parse these as PHP with the parent script when they get included, just make sure you surrond your code blocks in PHP tags.One tip I would recommend you to do is prehaps save your files as filename.inc.php so you can easily identify your files that get included from the normal .php files. Quote Link to comment Share on other sites More sharing options...
completeamateur Posted April 5, 2006 Author Share Posted April 5, 2006 Cheers guys, I wouldn't have thought about exposing code when not using ".php". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.