#31491 [Opn->Fbk]: Comment (/* */) parsing is also done inside strings

From: Date: Tue, 11 Jan 2005 11:56:15 +0000
Subject: #31491 [Opn->Fbk]: Comment (/* */) parsing is also done inside strings
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969365914@lists.php.net to get a copy of this message
ID: 31491 Updated by: tony2001@php.net Reported By: jeroen at unfix dot org -Status: Open +Status: Feedback -Bug Type: Zend Engine 2 problem +Bug Type: Documentation problem Operating System: any PHP Version: 5.0.3 New Comment: The docs clearly say: "You should be careful not to nest 'C' style comments, which can happen when commenting out large blocks." (c) http://www.php.net/manual/en/language.basic-syntax.comments.php Previous Comments: ------------------------------------------------------------------------ [2005-01-11 12:48:43] jeroen at unfix dot org Compiling that works fine with GCC++, Intel C++ and Visual C++. Thus fix the documentation on the PHP site. Indeed, it does not compile with C, but it does with a C++ compiler. C doesn't allow nested /* */ commenting. ------------------------------------------------------------------------ [2005-01-11 12:33:53] tony2001@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 Try to compile this: #include <stdlib.h> int main() { /* printf("*/"); */ return 1; } ------------------------------------------------------------------------ [2005-01-11 12:23:48] jeroen at unfix dot org Description: ------------ Comments (/* */) are parsed wrongly. This works in most (if not all) C-compilers, with a similar construct. "http://www.php.net/manual/en/language.basic-syntax.comments.php" notes: "PHP supports 'C', 'C++' and Unix shell-style comments." And there are two other similar bug reports (Bug #31395: incorrect parsing of comments), and quite apparently PHP does *NOT* support C++ style comments. If it did it would not barf at the above. Reproduce code: --------------- <?php /* echo "*/"; */ echo "Blaat\n"; ?> Expected result: ---------------- Blaat Actual result: -------------- --- 5.0.3 --- $ /opt/php/5.0/bin/php tst.php PHP Parse error: parse error, unexpected T_STRING in /tmp/tst.php on line 6 Content-type: text/html X-Powered-By: PHP/5.0.3 --- 4.3.10-2 (debian's php4-cli 4:4.3.10-2) --- $ php -v PHP 4.3.10-2 (cli) (built: Dec 19 2004 03:41:45) $ php tst.php Parse error: parse error, unexpected T_STRING in /tmp/tst.php on line 6 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31491&edit=1

« previous php.doc (#969365914) next »