[PHP Includes] Simple - but confused?

Hi there,

Sorry to drag up an old topic, but my I ask why the require function is better than include?

or is this the only advantage:

php.net said:
require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, don't hesitate to use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well.

Thanks...
 
Dj_Jestar said:
__FILE__ would also relate to which ever file is doing the including, unfortunately. :)

I know for a fact it doesn't, seriously.

Stick this in foo.php:

Code:
<?php

var_dump(__FILE__);

?>

this in bar.php:

Code:
<?php

require 'foo.php';

?>

and run both. The output is

Code:
string(7) "foo.php"

on both of them :)
 
Conrad11 said:
Hi there,

I am stuck on using an Include in PHP. I have tried:

Basic Include:
Code:
<?php
include 'includes/theader.inc';
include 'tutorials.inc';
include 'includes/tfooter.inc';
?>

Http Include:

Code:
<?php
include 'http://www.bf2tricks.ubersol.co.uk/verynew/includes/theader.inc';
include 'http://www.bf2tricks.ubersol.co.uk/verynew/tutorials.inc';
include 'http://www.bf2tricks.ubersol.co.uk/verynew/includes/tfooter.inc';
?>

The three files are:

theader.inc (In an includes folder)
tfooter.inc (In an includes folder)
tutorials.php (In the same folder)

I am trying to include them all together to make my page and I get nothing: Click Here. What am I doing wrong?

Thanks...

[Edit]

As there is no index page as of yet, you can view my file structure: Click Here

You forgot the brackets, its:

Code:
include ('includes/theader.inc');
 
d'oh yea - it was the exec() command I remember spending hours trying to figure it why it was not working a while ago - forgot brackets :p

Edit: also just read the whole thread - php t'aint working on that host.
 
Last edited:
Back
Top Bottom