php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60777 bug in parsing one line comment
Submitted: 2012-01-17 13:40 UTC Modified: 2012-01-17 18:33 UTC
From: giguet at ens dot fr Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS: linux squeeze
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: giguet at ens dot fr
New email:
PHP Version: OS:

 

 [2012-01-17 13:40 UTC] giguet at ens dot fr
Description:
------------
When the two character-string ?> is present in a one-line // comment
php interprets the rest of the line as php code.

PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

Test script:
---------------
<?php

// echo '?>';

?>


Actual result:
--------------
';


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-17 13:46 UTC] laruence at gmail dot com
bogus, The "one-line" comment styles only comment to the end of the line or the 
current block of PHP code, 
see http://www.php.net/manual/en/language.basic-syntax.comments.php
 [2012-01-17 15:34 UTC] giguet at ens dot fr
In my script this is a one line comment style and it does not comment to the end of the line. If it was the case, php would not display the ;' following ?>
 [2012-01-17 16:44 UTC] mike@php.net
But you end the current PHP block with ?>. The parser doesn't care that the code 
in the comment would be valid.
 [2012-01-17 16:44 UTC] mike@php.net
-Status: Open +Status: Bogus
 [2012-01-17 18:33 UTC] giguet at ens dot fr
Thank you for your useful comments.

I thought php would have parsed until the end of line, whatever the content is.
When you comment this kind of line, it's not easy to remember
that the ?> will close the php block since it is not clear.
In my code it was a // $content = preg_replace('~<.*?>~','',$content); which generated the problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 06:01:31 2024 UTC