php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18151 Comments not being stripped.
Submitted: 2002-07-03 17:50 UTC Modified: 2002-09-15 18:02 UTC
From: polone at townnews dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.0 OS: Linux 2.4.18
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: polone at townnews dot com
New email:
PHP Version: OS:

 

 [2002-07-03 17:50 UTC] polone at townnews dot com
The php -w option also strips comments outside of the PHP tags. Thus, a program like:

#!/usr/bin/php -q
<?php

    // Bye-Bye comment

    print "hello world\n";

?>

Would end up like:

<?php
  print "hello world\n"; ?>

But, this is incorrect. It should be:

#!/usr/bin/php -q
<?php
  print "hello world\n"; ?>

It appears this only happens if the first line in the file is formatted like a PHP comment. Thus,

# This is not a PHP comment!!!!
<?php

   print "hello world\n";

?>

Also strips the "# This is not a PHP comment!!!!".

Regards,

Patrick O'Lone
INN/TownNews.com
polone@townnews.com

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-04 03:59 UTC] sander@php.net
No, the CLI (and possibly the CGI too) is programmed to ignore the first line of a script if it starts with #.

Anyway, php -w (latest CVS) doesn't strip comments, although it's supposed to. (ab)using this report for that issue.
 [2002-09-15 18:02 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jun 09 22:00:02 2026 UTC