Jump to content

placement of include()


jim.davidson

Recommended Posts

I have a copywrite that I want to include on my site

 

I wrote a some code and called it copywrite.php

 

My question is...does it matter where I place <?PHP include('copywrite.php');?> on the page?

 

Should I put it at the very beginning of the code, inside the <head>, inside the <body>, or does it make absolutly no difference where it's placed?

 

Just wondering if it makes a difference.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/59261-placement-of-include/
Share on other sites

When you include a file, it is parsed as if the contents of the included file was already in the file that is calling your include, and is wherever you call it. Therefore, the placement depends on what it does. For example, if it were to output some text(Copyright jim.davidson 2007 for example), then you'd obviously want to include this wherever you wanted the copyright notice displayed.

Link to comment
https://forums.phpfreaks.com/topic/59261-placement-of-include/#findComment-294331
Share on other sites

It depends on what's in the file and where you want it to appear.

 

Whatever text, code, etc. is in that file will be placed exactly where you put the include.

 

index.php:

<?php
echo "world";
include "hello.php";
?>

 

hello.php:

<?php
echo "hello";
?>

 

Will show:

world hello

Link to comment
https://forums.phpfreaks.com/topic/59261-placement-of-include/#findComment-294333
Share on other sites

I understand what you're saying but what if, as in my case the include file (copywrite.php) says where the placement is i.e. a layer? That's why I wondered if made a difference where it's placed in the code.

 

The reason I'm asking this is that I'm getting an error on my site but so far the error only shows up on two of a dozen different pcs that I've ran it on.

(CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers).

 

I'm grasping at straws trying to come up with a reason for the error.

 

By the way the error only happens with IE6 or IE7, Firefox and Netscape works fine on all pcs tested.

Link to comment
https://forums.phpfreaks.com/topic/59261-placement-of-include/#findComment-294341
Share on other sites

The reason I don't show the code is that the error pops up at different times on different pages of the site.  One time you'll click on a link and it works fine, 30 seconds later, click on the same link and you get the error - CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. go to another page on the site, come back, click on that link again and it will work fine.

 

But so far it's only happens on two different pc's one running IE6 the other running IE7.  Run on these pc using Firefox or Netscape can't get the error.

 

Try it yourself www.bobtracyinsurance.com/index.php, see if you can get an error.

 

I gladly post the code for the whole site, but I don't think that would be welcomed since there are fourteen different pages and the error could/has popped up on any of them.

 

I would be very grateful for any ideas on what's causing this.

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/59261-placement-of-include/#findComment-294380
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.