11/17/06

Comments are not Ignored Within Here-doc method in PHP

Consider the following block of code:

 

<?php

echo <<< EXAMPLESTRING

 

my string contents

 

EXAMPLESTRING;

?>

 

The above code prints:

 

My string contents

 

Not consider the following block of code:

 

<?php

echo <<< EXAMPLESTRING

 

//the string contents go here

 

my string contents

 

EXAMPLESTRING;

?>

 

This example prints:

 

//the string contents go here

 

My string contents

 

So we cannot use comments in here doc method.

The amusing part is that Dreamweaver can't understand this rule and shows the comments in here doc like other comments but Zend Studio shows them like other strings in the here doc section.

2 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.