strange unexpected $end
Posted: Tue Nov 27, 2007 10:30 pm
I know this usually indicates a missing curly brace. But I've went through and matched mine up (of course there's room for human error there).
Anyways, here's this snippet of code
With that code not commented out, I get Parse error: syntax error, unexpected $end
So then I comment that entire function out with /* */ comment
Now the script works, except of course, it can't use that function. Funny thing is, when I comment the whole function out with // style comments like this:
I get this error: Parse error: syntax error, unexpected ';', expecting T_FUNCTION. Weird.. I didn't know the comment style mattered.
Next, I comment out only the "meat" of the function using //:
Now I get Parse error: syntax error, unexpected $end
If I comment out the "meat" of the function using /* */ like this
The code will run (but of course, can't use this function).
What the heck is going on here? I was very careful to make sure exactly what I put in this post is exactly what I'm doing.
Anyways, here's this snippet of code
Code: Select all
private function _getPHPCode()
{
if ($this->_PHPOnly)
{
//multiple php blocks, or single php block with closing tag, matches <? or <?php or <% and %> or ?>
if (preg_match_all("/<((\?|%)|(php)?).+?(\?|%)>/sm", $this->_code, $matches))
{
$this->_code = implode("\n", $matches[0]);
}
}
}So then I comment that entire function out with /* */ comment
Code: Select all
/*private function _getPHPCode()
{
if ($this->_PHPOnly)
{
//multiple php blocks, or single php block with closing tag, matches <? or <?php or <% and %> or ?>
if (preg_match_all("/<((\?|%)|(php)?).+?(\?|%)>/sm", $this->_code, $matches))
{
$this->_code = implode("\n", $matches[0]);
}
}
}*/Code: Select all
//private function _getPHPCode()
//{
// if ($this->_PHPOnly)
// {
// //multiple php blocks, or single php block with closing tag, matches <? or <?php or <% and %> or ?>
// if (preg_match_all("/<((\?|%)|(php)?).+?(\?|%)>/sm", $this->_code, $matches))
// {
// $this->_code = implode("\n", $matches[0]);
// }
// }
//}Next, I comment out only the "meat" of the function using //:
Code: Select all
private function _getPHPCode()
{
//if ($this->_PHPOnly)
//{
// //multiple php blocks, or single php block with closing tag, matches <? or <?php or <% and %> or ?>
// if (preg_match_all("/<((\?|%)|(php)?).+?(\?|%)>/sm", $this->_code, $matches))
// {
// $this->_code = implode("\n", $matches[0]);
// }
//}
}If I comment out the "meat" of the function using /* */ like this
Code: Select all
private function _getPHPCode()
{
/*if ($this->_PHPOnly)
{
//multiple php blocks, or single php block with closing tag, matches <? or <?php or <% and %> or ?>
if (preg_match_all("/<((\?|%)|(php)?).+?(\?|%)>/sm", $this->_code, $matches))
{
$this->_code = implode("\n", $matches[0]);
}
}*/
}What the heck is going on here? I was very careful to make sure exactly what I put in this post is exactly what I'm doing.