php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18987 PHP Engine parsing commented code
Submitted: 2002-08-20 12:02 UTC Modified: 2002-08-20 15:21 UTC
From: xilord at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.2 OS: Windows/Linux
Private report: No CVE-ID: None
 [2002-08-20 12:02 UTC] xilord at yahoo dot com
Can duplicate on Windows 2k and Linux
// $patt = "/(^\s*<p[^>]*?>)|(<\/p>$)/i";
-------------------------}
PHP is parsing the commented code and closing the script block at the "?>".

Haven't found anything on this issue in the Bug db. I know there are obvious work-arounds but I thought I'd mention it.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-20 12:03 UTC] edink@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.


 [2002-08-20 13:56 UTC] xilord at yahoo dot com
"Your problem does not imply a bug in PHP itself."
I'm not sure if I'm wrong in saying this, but last I checked, commented code should never be parsed by any compiler/runtime. The fact that PHP is reading the commented code implies a parsing issue.

If I'm incorrect in saying this, please let me know.
 [2002-08-20 14:31 UTC] nohn@php.net
So for example
<?php
  echo("test<br>");
  // echo("lala<br>");
  echo("bubu<br>");
?>

gives out

test
lala
bubu

on your system?
 
 [2002-08-20 14:43 UTC] xilord at yahoo dot com
Not necessarily.

If you enter this exact line of code:
// $patt = "/(^\s*<p[^>]*?>)|(<\/p>$)/i";
--------------------------*
The php engine parses out the ?> as the end of the PHP script block (which isn't the case.) In my example, I'm using *? as the quantifier minimizer then the ">". PHP sees "?>" and kills the script.

Your example doesn't have the ?> commented out. Granted it's not frequent that you'd have this combination anywhere in your code, but in this example it is happening.

Try doing this:
// ?>
And see what happens.
 [2002-08-20 14:51 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2002-08-20 15:21 UTC] xilord at yahoo dot com
I found this in the documentation:
"The "one-line" comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first."

Looks like it answers my question, but the concern is still there. Thanks for the help.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 21:01:32 2024 UTC