php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8233 # and // don't work as comment, whereas /*..*/ do
Submitted: 2000-12-13 10:30 UTC Modified: 2000-12-13 15:34 UTC
From: stefan dot peer at tiwag dot co dot at Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: Linux Kernel 2.2.14, Apache 1.3.
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stefan dot peer at tiwag dot co dot at
New email:
PHP Version: OS:

 

 [2000-12-13 10:30 UTC] stefan dot peer at tiwag dot co dot at
Hi, I had a problem commenting out code fragments.
The problem within the following lines is the single-line comment //
# as comment seems to have the same problem whereas /* ... */ works fine.

if( preg_match( "/(.*?)ELEMENT_(\d+)\{(.*?)\}((<.*?>)+)/", $template_lines[$j], $matched) ){ 
    //preg_match("/(.*?)ELEMENT_LAST\{(.*?)\}((<.*?>)+)/", $template_lines[$j], $matched)
    $debug_msg .= "Matched /(.*?)ELEMENT_(\d+)\{(.*?)\}((<.*?>)+)/ within X";
    $iterations = $matched[2];
    break;
}
These lines bring up the errormessage "Parse error: parse error in includes/functions.inc on line 408", where 408 is the last line of the file.

I am not sure, whether this has to do with commenting out regular expressions.
By the way, I'm using Apache 1.3.14, SuSE 6.4 Linux and I've compiled php with the following switches:
./configure --with-apache=/root/apache/apache_1.3.14 
                 --with-mysql=/usr/local/mysql 
                 --with-config-file-path=/usr/lib 
                 --with-pdflib=/usr/lib/libpdf.so 
                 --with-gdbm=/usr/lib/libgdbm.so 
                --enable-ftp 
                --enable-filepro 
                --with-java=/usr/lib/java 
                --with-ldap 
                --with-openssl=/usr/local/openssl 
                --enable-sysvsem 
                --enable-sysvshm 
                --enable-track-vars

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-13 14:22 UTC] jmoore@php.net
Note from Chris Newbill <cnewbill@onewest.net>
------------------------------------------
I don't have the ability to update bugs, but I can duplicate this problem.

If you escape ?> in your commented line it should work fine.  ie \?\>

You can reproduce this with the following simple script. (it only happens in
logical blocks.)

<?php

if (true) {
// ?>
}

?>

By contrast this script (outside of a logical block)

<?php
//?>
?>

Would actually print "?>" to the screen

Chris

 [2000-12-13 15:34 UTC] joey@php.net
http://www.php.net/manual/language.basic-syntax.comments.php
The "one-line" comment styles actually only comment to the
end of the line or the current block of PHP code, whichever
comes first.

The parser sees ?> as the end of the block of PHP code.
The function call is not being interpreted, so the engine
does not know what context it is running under.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 03:01:35 2025 UTC