Why does include use quotes instead of brackets?

A statement to include a file looks like this:

include 'file_to_include.php';

Why is it not like this?

include(file_to_include.php);

Thanks!

You mean “parentheses”

Any way, parentheses are used for functions. include (and a few other things) are -not- functions, as you yourself said, they’re “statements”.

So you don’t need to use the parenthess. Many do use them, which adds to the misconception many have. But that’s the lowdown.

An include is a language construct, which is why the parentheses is optional.

On a side note, when you include a file without a full path name, add ./ in front of the name, to avoid PHP first checking any include folders setup in the ini file.

Example:

include './file_to_include.php'; 
include('./file_to_include.php'); 

You can check out the other language constructs PHP has here:
http://www.php.net/manual/en/reserved.keywords.php

Yes, he said so in the title :wink: Joke aside, he is from Ireland and they normally say brackets and not parentheses there (UK, Australia and perhaps other countries as well).

Thanks for the much better explanation @TheRedDevil;

I can overlook the brackets vs. parentheses thing seeing as I should have said language construct but said statement :shifty:

Thanks Mittineague and TheRedDevil for the helpful explanations and links.

Yes we do, sorry for the confusion :slight_smile: