|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-11-28 10:54 UTC] hervecaussinus at yahoo dot ca
Description:
------------
I am not able to use the class examples in your Web site. In fact it seems that it is impossible to declare a variable when defining a class.
I am very new to PHP (3 days). Sorry if I am doing something wrong.
I look at the bug database and I also download and install the last binary (php5-win32-200311281530.zip).
Reproduce code:
---------------
<?php
class MyClass {
$Hello = "Hello, World!\n";
}
print 1;
?>
Expected result:
----------------
Should parse and display 1 .
Actual result:
--------------
Gives this error:
Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in c:\inetpub\wwwroot\CorePHP\6-1.php on line 3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 17:00:01 2025 UTC |
I test the syntax: <?php class MyClass { public $Hello = \"Hello, World\\n\"; } print 1; ?> and it does not work. Once again I am very sorry if I am doing something wrong (that is possible due to my short experience) but I think it is a bug (that looks strange I must admit).Remove the Backslashes ( your string wasn't enclosed ) <?php class MyClass { public $Hello = "Hello, World\n"; } print 1; ?>