[ciapug] heredoc

Chris Van Cleve vanish at dreamscapevisionery.com
Mon Mar 13 14:53:52 CST 2006


Say I have the following code which inserts content into a web page  
through a class:

// Add something to the body of the page
$webPage->addContent("
     <h1>Administration Menu</h1>
     <dl>
     	<dt><a href='ticker.php'>Headline Ticker Management</a></dt>
     		<dd>View, Add, Edit, Delete items for the Headline Ticker</dd>
     	<dt><a href='news.php'>News Management</a></dt>
     		<dd>View, Add, Edit, Delete, Publish items for departmental  
and company-wide news</dd>
     	<dt><a href='#'>Event Management</a></dt>
     		<dd>View, Add, Edit, Delete items from the company-wide  
calendar of events</dd>
     </dl>
     " );

But I want to use heredoc syntax instead of the long quoted string.  
When I try this:

// Add something to the body of the page
$webPage->addContent(<<<HTML
     <h1>Administration Menu</h1>
     <dl>
     	<dt><a href='ticker.php'>Headline Ticker Management</a></dt>
     		<dd>View, Add, Edit, Delete items for the Headline Ticker</dd>
     	<dt><a href='news.php'>News Management</a></dt>
     		<dd>View, Add, Edit, Delete, Publish items for departmental  
and company-wide news</dd>
     	<dt><a href='#'>Event Management</a></dt>
     		<dd>View, Add, Edit, Delete items from the company-wide  
calendar of events</dd>
     </dl>
HTML;
      );

It breaks. This is the only situation I've come across where I can't  
get heredoc to work. Granted I haven't spent a great deal of energy  
on solving this because it's an issue of convenience, but before I  
got troughing the php.net comments I thought I would see if someone  
here had some quick insight for me.

Chris VC



More information about the ciapug mailing list