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

Seb seb at members.evolt.org
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 ?>.
>
><?php
>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 'testing.inc' ?>

<?php
include 'testing.inc';
?>

<?


include                        'testing.inc'               ;


?>


<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 <<<.
EOF;

?>

</tip>

Seb.




More information about the thelist mailing list