php includes (was Re: [thelist] SSI Brain Fart)

Seb seb at
Mon May 6 17:08:00 CDT 2002

>NanHarbisonSmith wrote:
>Doesn't the include have to be in parentheses? (I am not sure, but I always
>use them in require and include statements.)  And you should not leave blank
>lines between the <?PHP and ?>.
>include ('http://some-url');

include is actually a language control structure (like require, echo,
print, etc), so does not require the parentheses.

Whitespace between <?php and ?> tags is essentially irrelevant, as long as
your code is syntactically correct. For example, the following 3 code
snippets are equivalent:

<?php include '' ?>

include '';


include                        ''               ;


<tip type="PHP language constructs">

Get to know the language constructs (include, require, print, echo, etc) in
PHP. As well as behaving like functions, they also have extensive
additional properties and behaviours that offer a great deal of flexibility.

For example, instead of just calling:
<? print( "This is a test" ); ?>

You can do things like:

$amazing = 'remarkably useful';

print <<<EOF There are some $amazing things that you can do
with PHP language constructs, including the use of
HEREDOC functionality within print statements.
Just remember to have your terminator on a separate line
followed by a semicolon, and to have no whitespace after the
opening <<<.




More information about the thelist mailing list