FRIHOST • FORUMS • FAQ • TOS • BLOGS • DIRECTORY
You are invited to Log in or Register a Frihost Account!

what are the differents between require and include

 


haziwkd
are they same as die() & exit()?
sonam
For me required and include is very different commands, same like die() and exit(). But many people thinking both are same. Try to put somewhere in HTML (but not on bottom) include_once command, and don’t create included file. E.G. <? include_once('dataaaas.txt'); ?>
Now run this PHP page. You will see your page is ok. Dataaas.txt is not included but everything other looking good. Now, change include u require, and everything below require command will lose!
Differences???

Sonam
P.S. I am tested this only on Windows, but I thing it is same on Linux.
mathiaus
Quote:
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.

as found on http://uk2.php.net/require

May I suggest checking the php documentation. It is actually really helpfull and quite through Wink
http://uk2.php.net/manual/en/index.php

If you cant work out the naviagtion use their search feature!
sonam
Great post Matt,
You are right, require() and include() do same thing but on error results are different. In that case we can conclude:
require() == include() is TRUE
require() === include() is FALSE

Rolling Eyes
Sonam
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.