[thelist] Php Heredoc syntax

Russell Griechen russgri at bellsouth.net
Thu Jul 31 19:49:05 CDT 2003


In order to enable global includes...I have been toying around with heredocs
syntax.
The code;

/*  include1.php  */

<?php
$html = <<<END
<html>
<head>
<title>Sportsmen Afield|&nbsp;&gt;Zarahost/index1.php
 <?php
 echo($title);
 ?></title>
</head>
END;
?>
<?php
$body = <<<END
<body>
echo Hello World
END;
?>
<?php
$footer = <<<END
Copyright &copy; 1998-2002 - Mysite.Com/Mysitename All Rights Reserved -
<a href="mailto:info at sportsmenafield.com"style="color:beige">Webmaster</a>
</body></html>
END;
?>
 /*  index1.php  */
<?php
include("include1.php");
echo $html;
echo $body;
?>
Hello World
<?
echo $footer;
?>
------------
This does not work... and I haven't found the culprit.
Here is the browser content which contains an error  message:

Parse error: parse error, unexpected T_SL in
/home/httpd/vhosts/sportsmenafield.com/httpdocs/xarahost/include1.php on
line 13
Hello World

Here is the 'Source code in the browser:

<br />
<b>Parse error</b>:  parse error, unexpected T_SL in
<b>/home/httpd/vhosts/sportsmenafield.com/httpdocs/xarahost/include1.php</b>
on line <b>13</b><br />

Hello World

Russell Griechen



More information about the thelist mailing list