|
-
May 23rd, 2007, 10:49 PM
#1
Thread Starter
Fanatic Member
PHP4: Constant inside a class
This gives me PHP Parse error: syntax error, unexpected ';', expecting '(' in C:\Program Files\Apache Group\Apache2\htdocs\toolmon\_debug_tmp.php on line 15 having a code
Code:
class test {
var $SOME_CONST = 10;
}
echo test::$SOME_CONST;
Can't I create a constant variable inside a class?
Thanks.
Last edited by nebulom; May 24th, 2007 at 05:36 AM.
-
May 24th, 2007, 01:57 AM
#2
Re: PHP4: Constant inside a class
I don't think so, only instance variables. Constants are static.
-
May 24th, 2007, 05:29 AM
#3
Re: PHP4: Constant inside a class
 Originally Posted by nebulom
This gives me PHP Parse error: syntax error, unexpected ';', expecting '(' in C:\Program Files\Apache Group\Apache2\htdocs\toolmon\_debug_tmp.php on line 15 having a code
Code:
class test {
var $SOME_CONST = 10;
}
echo test::$SOME_CONST;
 Can't I create a constant variable inside a class?
Thanks.
I suggest you do what most other packages do:
PHP Code:
define('CLASSNAME_CONST_NAME', 1);
Its not a class constant but it signifies its relation to the class. I also suggest you upgrade to PHP 5
-
May 24th, 2007, 05:35 AM
#4
Thread Starter
Fanatic Member
Re: PHP4: Constant inside a class
Hehe. Will do upgrade soon. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|