Jump to content

Using php include for header and navigation - bad practice?


Recommended Posts

There's an obvious advantage to using php include for the header section of my site: in the future I'd only have to edit the one file.

 

Will it affect search engines or will search engines always detect the parsed code? Any other reason(s) why this might be considered bad practice?

Using includes will not effect SEO at all. When a client (whether it be a person or a crawler/spider) requests a page all they see is the output, it will have no idea whether includes were used or not. Since PHP is a server side technology, this is processed out of the page before the client ever gets to see the content.

Not a bandwidth issue but one "negative" (depends which way you look at it) about using absolute paths is they will only parse the output of the script.

 

I 'think' that files included from a remote location only include the output of that script, not the variables or functions. I remeber seeing a topic about includes a few months ago and this was one of the things brought up.

 

 

 

 

Not a bandwidth issue but one "negative" (depends which way you look at it) about using absolute paths is they will only parse the output of the script.

 

I 'think' that files included from a remote location only include the output of that script, not the variables or functions. I remeber seeing a topic about includes a few months ago and this was one of the things brought up.

Nobody mentioned including a file remotely, only including files. Any variables declared above an included file can be used in the included file and on the flip side anything declared in the included file can be used below the include statement.

 

If I'm using the include function I'll need to use absolute paths.

 

Is there any downside to having to use absolute paths over relative paths (maybe in terms of bandwidth?)

 

:confused:

Generally people will use $_SERVER['DOCUMENT_ROOT'], a user defined constant and/or __FILE__ when working with includes. Finding the right mix of these can be a pain and depends entirely on what exactly your attempting to achieve.

@mattyvx: Cheers, but that's going over my head a little.  :shy:

 

@cags: I've seen shortcut constants like that used in WordPress.

 

I basically have a header section that's universal to every page of the site (including the blog and forum subsections).

 

Based on that criteria should $_SERVER['DOCUMENT_ROOT'] do the trick?

 

I'm not sure why I'd need to find the right mix with the other options you've provided.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.