php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17895 Strange bug about comments
Submitted: 2002-06-21 07:26 UTC Modified: 2002-06-21 09:30 UTC
From: php at ak-dev dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.1.2 OS: Windows 2000
Private report: No CVE-ID: None
 [2002-06-21 07:26 UTC] php at ak-dev dot com
I think I have found a strange bug, but I am not sure it is one!

I explain my problem:

//?>
#?>

If you insert one of those two previous lines, the parse will crash!
In my mind, # or // are 'one line comments' and in this way, it has to be impossible to execute code on the same line after those comment tags, but here it is possible!
So it is very dangerous to put //?> or #? in your source code!

In some cases, it does a crash and it results a parse error, and in others cases it displays source code of the file!!

In my mind, it is not normal...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-21 07:35 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-06-21 08:27 UTC] hholzgra@php.net
http://www.php.net/manual/en/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. This means that HTML code after // ?> WILL be printed: ?> skips out of the PHP mode and returns to HTML mode, and // cannot influence that."
 [2002-06-21 08:41 UTC] php at ak-dev dot com
It means that you cannot write this type of code:  !?


<?


//  previous code
//  mysql_connect('otherhost', 'toto', 'titi');
//
//?>
//

  mysql_connect('localhost', 'riri', 'fifi');

?>

This code has no real way, but it represents a problem, real code could be similary for other problems!

but you can write this:

<?

/* previous code

  
  mysql_connect('otherhost', 'toto', 'titi');

?>

*/

  mysql_connect('localhost', 'riri', 'fifi');

?>

In my mind, even if it is a bug, it is the right way to do!
a one-line comment has to comment to the end of the line in EVERY CASE!!!!
 [2002-06-21 08:46 UTC] cynic@php.net
This ain't gonna change.

 [2002-06-21 09:30 UTC] hholzgra@php.net
please take in account that PHP is only embedded
in a surrounding context as a XML processing instruction

so ending the processing instruction block with ?>
als ends any embedded comments 

you may not like it and it can be confusing,
but is the right and only way to go 
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 12:00:02 2026 UTC