Home Php php include and require
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

php include and require

Advertisement
In php include and require are almost same but the difference between these two is require

php include and require

     

In php include and require are almost same but the difference between these two is require generates fatal error and does not allow any valid syntax to be displayed where on the other hand include does allow the valid syntax to be displayed which should not be consider as good programming practice at all.

In the following examples we will see how these two statements include and require are different.

Example (using include):

<?php

include ('NewAjax.php');

echo "This is a line";

?>

Output:

Warning: include(NewAjax.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\php_advance\radioAjax.php on line 2
Warning: include() [function.include]: Failed opening 'NewAjax.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\php_advance\radioAjax.php on line 2
This is a line

Example (using require):

<?php

require('NewAjax.php');

echo "This is a line";

?>

Output:

Warning: require(NewAjax.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\php_advance\radioAjax.php on line 2
Fatal error: require() [function.require]: Failed opening required 'NewAjax.php' (include_path='.;C:\php5\pear') in C:\wamp\www\php_advance\radioAjax.php on line 2 

As above output, require generates Fatal error: and does not executes the valid lines as well.

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 17, 2009

Ask Questions?    Discuss: php include and require  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com