php bug? strange end of php file error

php bug? strange end of php file error

am 07.09.2007 17:31:09 von Zanna

Why this code

function X()
{
// echo("commented ?>");
}
X();
?>

give the error
"Parse error: syntax error, unexpected $end"

???

?> is into a string commented!

Re: php bug? strange end of php file error

am 07.09.2007 17:46:26 von gosha bine

On 07.09.2007 17:31 Fabio wrote:
> Why this code
>
> > function X()
> {
> // echo("commented ?>");
> }
> X();
> ?>
>
> give the error
> "Parse error: syntax error, unexpected $end"
>
> ???
>
> ?> is into a string commented!

no, it is not. There's no "strings" inside comments, comment is a stream
of characters and does take ?> into account. I don't think this is a
good idea either, but so is it.

--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi

Re: php bug? strange end of php file error

am 07.09.2007 22:05:19 von Zanna

"gosha bine" ha scritto nel messaggio
news:46e17257$0$31118$6e1ede2f@read.cnntp.org...
> On 07.09.2007 17:31 Fabio wrote:
>> Why this code
>>
>> >> function X()
>> {
>> // echo("commented ?>");
>> }
>> X();
>> ?>
>>
>> give the error
>> "Parse error: syntax error, unexpected $end"
>>
>> ???
>>
>> ?> is into a string commented!
>
> no, it is not. There's no "strings" inside comments, comment is a stream
> of characters and does take ?> into account. I don't think this is a good
> idea either, but so is it.

but

/* echo("commented ?>"); */

works well... :(

Re: php bug? strange end of php file error

am 07.09.2007 23:26:22 von gosha bine

Fabio wrote:
> "gosha bine" ha scritto nel messaggio
> news:46e17257$0$31118$6e1ede2f@read.cnntp.org...
>> On 07.09.2007 17:31 Fabio wrote:
>>> Why this code
>>>
>>> >>> function X()
>>> {
>>> // echo("commented ?>");
>>> }
>>> X();
>>> ?>
>>>
>>> give the error
>>> "Parse error: syntax error, unexpected $end"
>>>
>>> ???
>>>
>>> ?> is into a string commented!
>> no, it is not. There's no "strings" inside comments, comment is a stream
>> of characters and does take ?> into account. I don't think this is a good
>> idea either, but so is it.
>
> but
>
> /* echo("commented ?>"); */
>
> works well... :(
>
>
>
>
Yet again, this has nothing to do with if you have quotes inside
comments or not. "/* blah ?> */" doesn't break out of php mode, "// blah
?>" or "# blah ?>" do. A bit odd in my opinion, but this is how it's
intended to work (see Language/Comments in manual).




--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok