ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
#31787 [Opn]: Parse Error -- Comment of // slash slash fails to ignore script terminator
by Codeslinger At Compsalot Dot Com other posts by this author
Jan 31 2005 3:47PM messages near this date
#31787 [Opn->Bgs]: Parse Error -- Comment of // slash slash fails to ignore script terminator | #31786 [NEW]: Zend/zend_strtod.c contains invalid pre-processing error info
ID:               31787
 User updated by:  codeslinger at compsalot dot com
 Reported By:      codeslinger at compsalot dot com
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      4.3.10
 New Comment:

I doubt it makes a difference, but this is the CLI version of php.


Previous Comments:
------------------------------------------------------------------------

[2005-02-01 00:36:23] codeslinger at compsalot dot com

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 this bug report at http://bugs.php.net/?id=31787&edit=1
Thread:
Codeslinger At Compsalot Dot Com
Codeslinger At Compsalot Dot Com

Codeslinger At Compsalot Dot Com

Codeslinger At Compsalot Dot Com

Codeslinger At Compsalot Dot Com

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved