hello now i have class
class test{
var $var_test = 'test';
}
how i can get it
i think
$t = new test();
echo $t->var_test;
is this true
hello now i have class
class test{
var $var_test = 'test';
}
how i can get it
i think
$t = new test();
echo $t->var_test;
is this true
Have you tried it?
But yes, that is true. (It would be better to declare the member with public if you're going to access it from outside the class.)
If your variable is public, yes. Be sure to use proper visibility for your variables and methods.
Typically, you'll want to use get() and set() methods to handle data within the class itself. These keeps people's grubby hands off of your data :) Generally these will return the value from within the class ( return $this->val; ) so nobody is directly able to access the variable.
If you are wondering if
$t = new test();
echo $t->var_test;
is correct, then the answer is yes. I guess that you made the question because you are having problems with code you developed, and you want to understand why it is not working. If that is the case, then you should report the exact code you are using.
As side note, the code you are wrote is for PHP4; PHP5 uses a different syntax for class declaration, even though it is able to parse PHP4 classes.