Page 1 of 1

Heredocs parse error...

Posted: Wed Feb 01, 2006 4:18 pm
by raghavan20
When I run this code..I get this error..

Code: Select all

<pre>
<?php 

$input=<<<EOT
<body>
sample match 
<br />
<span style="text-decoration: underline">Special commands:</span>
<br />
<b>hi all</b> 
</body> 
EOT; 

echo preg_match_all("#<body>.*?<br />(.*?)<br /></body>#si", $input, $matches)."<br />"; 
print_r($matches); 

?> 
</pre>
Error...

Code: Select all

Parse error: parse error, unexpected $end in j:\apache\apache\htdocs\test\regex.php on line 18

Posted: Wed Feb 01, 2006 4:30 pm
by Weirdan
make sure there's no whitespace before ending EOT; or after the semicolon.

Posted: Wed Feb 01, 2006 4:43 pm
by raghavan20
There were spaces and I deleted them but even then it does not work..

Code: Select all

<pre> 
<?php  

$input=<<<EOT 
<body> 
sample match  
<br /> 
<span style="text-decoration: underline">Special commands:</span> 
<br /> 
<b>hi all</b>  
</body>  
EOT;
echo preg_match_all("#<body>.*?<br />(.*?)<br /></body>#si", $input, $matches)."<br />";  
print_r($matches);  

?>  
</pre>

Posted: Thu Feb 02, 2006 12:45 am
by Weirdan
there shouldn't be any whitespace after starting EOT as well

Posted: Thu Feb 02, 2006 4:04 am
by raghavan20
you are right Weirdan, there was a space after the initial EOT and now the problem is solved.

I am just curious what is the meaning of this error, T_SL. I am always not happy with the messages thrown by PHP on error.

Code: Select all

Parse error: parse error, unexpected T_SL in j:\apache\apache\htdocs\test\regex.php on line 13

Posted: Thu Feb 02, 2006 5:50 am
by Weirdan
raghavan20 wrote: I am just curious what is the meaning of this error, T_SL. I am always not happy with the messages thrown by PHP on error.

Code: Select all

Parse error: parse error, unexpected T_SL in j:\apache\apache\htdocs\test\regex.php on line 13
http://us2.php.net/manual/en/tokens.php