including includes ?
Is there a problem with including includes with PHP?
or even an included file that has an include in it?
(hope this doesnt confuse anyone lol)
would this add to server stress or anything?
Is there a problem with including includes with PHP?
or even an included file that has an include in it?
(hope this doesnt confuse anyone lol)
would this add to server stress or anything?
mairving posted this at 11:50 — 13th December 2001.
They have: 2,256 posts
Joined: Feb 2001
Not really any major problem. The only thing that people do wrong a lot is to name their includes like: header.inc, etc. I generally name mine something like headerinc.php, since if someone were to open that file in their browser, it would be parsed but the one with a .inc extension would show as plain text. It is not all that big a deal unless you have password/database settings in that include file. If that is the case, I will also place the includes in a folder below the documentroot of the website and link to it.
Here is an excellent article on PHP security.
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
Busy posted this at 22:19 — 13th December 2001.
He has: 6,151 posts
Joined: May 2001
What I want to do is have the header and footer section of the layout in the page, then in the middle (main table display section) have something like:
if ($pageid == pageone){
include ("pageone.php"); }
else if ($pageid == pagetwo) {
include ("pagetwo.php"); }
....
...
else { include ("mainpage.php"); }
and one of the php pages could have an include to a sub directory or something, the main reason i asked about including includes is i want to do this:
include ("sitespages.php (or .inc)") then in that page would be the above, so if i need to edit the pages contents just have to edit one page.
And each included page would have a script, that if the page wasnt called from the main page it would display a message ("umm your being naughty") and not display the contents - I love PHP
mairving posted this at 23:39 — 13th December 2001.
They have: 2,256 posts
Joined: Feb 2001
Are you pulling this data from a database? If not it would be easiest to have the page structure like so:
<?php
include(\"header.inc\");
Content for the page
include(\"footer.inc\");
?>
That way all you have to have is the content in the middle. You just have to make sure that your content fits your include structure. In other words, if you header.inc file ends with a , then your content needs to begin with a .
Your content page would be named pageone.php, etc. So to change the page structure just change the header or footer.
You can also have other 'modular' includes. I usually only show the copyright notice on the home page. So I will make that part a separate include, so that I can turn it on or off. Another piece of advice with using includes is to verify the HTML that comes from the PHP. It is too easy if you have several includes to not close a .
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
Busy posted this at 07:33 — 14th December 2001.
He has: 6,151 posts
Joined: May 2001
no database, just php or html files.
I looked at header and footer .inc but there is more content in them than there is in the actual page.
I read that link you gave - thanks and it mentioned .inc wasnt to secure, I'm not doing anything that is secret so shouldnt have any problems if it didnt display (except the layout wouldnt look good lol).
I also wouldnt have any tags starting or ending in either way (include or .inc), mostly plan text with an odd table here or there, but within the text content.
would either way be a stain on the server?
Suzanne posted this at 08:10 — 14th December 2001.
She has: 5,507 posts
Joined: Feb 2000
servers parse what they are told to parse.
if you have anything that needs parsing (like includes in includes), then everything from the main template on down has to be the right extension (.php in this case).
If you are just including files that have no scripting on them, and are only one level in, then you can name them .txt or .inc or .whatever and they will be simply tucked into the page before being rendered by the browser because they don't need to be parsed.
Suzanne
Busy posted this at 08:42 — 14th December 2001.
He has: 6,151 posts
Joined: May 2001
Thanks Suzanne, almost sounds like a tongue twister
Just had a thought, would includes affect search engine results, whether it be header/footer or content (I remember seeing something about this somewhere)
I've done this site in just html for a few years now but want to use my (limited) PHP knowledge, the more you do, the better you get and all that
mairving posted this at 15:04 — 14th December 2001.
They have: 2,256 posts
Joined: Feb 2001
It is not all that big a deal about includes if you are just using them as headers and footers. If you have an include that has a database username, password in it, then you should be concerned.
You can use either files with a .php or .html extension to parse php. Generally you would have to add a line like such to an htaccess file to get html parsed:
AddType application/x-httpd-php .html .htm
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
Suzanne posted this at 19:22 — 14th December 2001.
She has: 5,507 posts
Joined: Feb 2000
No -- when a page is put together on the server, it looks just like a hard coded page to the search engine. The only time that isn't the case is when you put the pages together through a search engine with a query string and don't map the url.
Suzanne
Busy posted this at 20:48 — 14th December 2001.
He has: 6,151 posts
Joined: May 2001
Thanks Mairving and Suzanne, I'm going to play around with a few ideas and see what trouble I can get myself into
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.