|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-06-17 10:17 UTC] stephane dot drouard at st dot com
Description:
------------
I'm using Dreamweaver and it handles editable regions by inserting HTML comments. To do so within PHP code, we need to close the script and to reopen it after.
It works fine within functions (including class functions), loops, if, ...
The only case (I identified) that does not work is within class definitions.
Reproduce code:
---------------
<?
class test {
?>
<!-- comment -->
<?
function test() {
print 'OK';
}
}
?>
Expected result:
----------------
It should compile
Actual result:
--------------
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <file> on line 3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 01:00:01 2025 UTC |
It might not be clear right away but this is how it's seen by PHP: <? class test { ; function test() { print 'OK'; } } From the manual, http://www.php.net/manual/en/language.basic-syntax.php "The closing tag for the block will include the immediately trailing newline if one is present. Also, the closing tag automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a PHP block."According to the answer, I added a variable but without terminating it by a ';': <? class test { var $dummy ?> <!-- comment --> <? function test() { print 'OK'; } } ?> It still reports the same error, but now at line 6, the opening PHP tag.