Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include() Why should I not use it?

I am working through an older php mysql book written in 2003. The author uses the include() function to construct html pages by including header.inc, footer.inc, main.inc files, etc. Now I find out that this is not allowed in the default ini settings, (allow_url_include is set to Off) after I got many warnings from the server.

I noticed also that you can use include without the parenthesis. I tried this and it works and I get no error messages or warnings. Are the two different? That is, is include() different from include ?

like image 664
aliov Avatar asked May 29 '10 22:05

aliov


1 Answers

This is a misunderstanding. You can turn off the inclusion of remote files (using a URL http://www.example.com/include.php instead of a filesystem path). You can always include local files.

The latter is because include is not a normal function, but a language construct. Like die, it can be used with or without parentheses. Source: Manual

Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value.

like image 76
Pekka Avatar answered Oct 22 '22 03:10

Pekka