FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free 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
Related topics
Choosing Between Free or Paid Web Hosting
Bluetooth
Frankfurt Motor Show, 2005
Formula 1
The Definative Web Hosting Guide
what are the differents between script and language?
writing COM components in Perl
[Resolved] Object Orientated PHP errors
Court whacks civil-liberties group, OKs Ten Commandments
Wonders of the include() in PHP.
SEO techniques
What is a site without tables?
Require and Include
long php pages or include
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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