faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 8 people (100%) answered Yes
Recently 8 of 8 people (100%) answered Yes

Entry

What is the difference between include() and @include()?

Mar 20th, 2008 16:56
ha mo, Philip Olson, tom leahy,


The @ is an error operator that is documented here:
  http://php.net/manual/en/language.operators.errorcontrol.php
It will hide an error that results when calling whatever has the @ in 
front of it.
So, if the include() fails (file not found, lack permissions to read, 
etc.) the error will be hidden.  In short:
  @include($file); // E_WARNING level error will be hidden if the
                      file cannot be found
  include($file);  // E_WARNING error will be shown if the file
                      cannot be found
Another option is error_reporting() which can hide errors for the 
entire script with just one call.  This can be set at runtime with the 
error_reporting() function or in php.ini (or .htaccess) and by default 
shows E_WARNING level errors.
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com