#31787 [NEW]: Parse Error -- Comment of // slash slash fails to ignore script terminator

From: Date: Mon, 31 Jan 2005 23:36:24 +0000
Subject: #31787 [NEW]: Parse Error -- Comment of // slash slash fails to ignore script terminator
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73164@lists.php.net to get a copy of this message
From:             codeslinger at compsalot dot com
Operating system: Linux
PHP version:      4.3.10
PHP Bug Type:     Scripting Engine problem
Bug description:  Parse Error -- Comment of // slash slash fails to ignore script terminator

Description:
------------
Here is a bizarre script parsing problem

The // comment operator is supposed to ignore everything on that line. 
But if you happen to do something like

// fwrite($pipes[0], "<?php echo 'Hello World';  ?>" );

Then you start getting all kinds of strange parse errors.

I isolated the problem.  What is happening is that

// ?>
or even  // "?>"

is being interpeted as the script terminator.

Happily  /*  ?>  */ does work


Reproduce code:
---------------
<?php

// ?>
  echo "we get an error because it sees the ?> in the comment";

?>

# The above will fail, but this works

<?php

/*
?>
*/
  echo "the ?> is properly ignored";

?>



Expected result:
----------------
anything and everything following a // to be ignored


Actual result:
--------------
Warning: Unexpected character in input:  '\' (ASCII=92) state=1 in
/foo/phpchild/parent1.php on line 29

Parse error: parse error, unexpected ')', expecting ',' or ';' in
/foo/phpchild/parent1.php on line 29


The actual error depends on the specific code following the termination
point.

This thing really had me baffeled for awhile...
I commented out several lines of code and started getting parse errors
about missing parens and semicolons, etc.

Depending upon what I commented out, the error would change, which made it
very hard to track down. Naturally I assumed I had made a mistake,
mismatched quotes etc. Took me quite a bit of head banging to finally
figure out what was going on.

=============
"Are you sure that you searched before you submitted your bug report?"

By the way....   You don't allow searching for specific characters such as
//  and  ?>   this makes it very hard to check for duplicates of this
bug....
   
I note that your auto-dup detector did search for // in fact it did a very
impressive job of finding similar bugs.  But no dups.



-- 
Edit bug report at http://bugs.php.net/?id=31787&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31787&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31787&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31787&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31787&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31787&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31787&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31787&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31787&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31787&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31787&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=31787&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=31787&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31787&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31787&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31787&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31787&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31787&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31787&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31787&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31787&r=mysqlcfg


Thread (8 messages)

« previous php.bugs (#73164) next »