PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Wed Feb 01, 2006 4:18 pm
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
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Wed Feb 01, 2006 4:30 pm
make sure there's no whitespace before ending EOT; or after the semicolon.
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Wed Feb 01, 2006 4:43 pm
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>
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Thu Feb 02, 2006 12:45 am
there shouldn't be any whitespace after starting EOT as well
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Thu Feb 02, 2006 4:04 am
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
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Thu Feb 02, 2006 5:50 am
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