Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
im trying to get a class to work in php (v4.4.1 on a linux server which i've been using for years), with public, private and static instance variables. i can use
var $varname = 'hello';to define just a normal instance variable (public) but for some reason if i say
public $varname = 'hello';
it will crash withparse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'
that happens if i try public, private, static, protected, or even public var $variable...the same thing happens if i try public function fname(){
all of this is inside the class MyClass
{ } brackets...and the class will function...almost normally if i take out all public, private, etc. types.
however when it DOES work, all my
var $var1;
var $var2;
have the same reference, so if i change one, they all change.
ie
$var1 = "hello";
$var2 = "there";
echo $var1 . $var2;
will output "therethere"
any help on either of these topics is greatly appriciated.

All those keywords are valid in PHP5, not version 4.x. There's no such thing as public, private, or static members in PHP 4.
-SN

Yeah, an to add to that, I would not use php5 untill it had gotten a little older. Never use a #.0 version, it might have issues that have not been worked out.
Siggy: Always check the manual first, Google helps too.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |