I have passed $attrib to $value by value
yes, didnt I mention that in an earlier post?
Look again at your most recent example.
Is it object oriented? No.
There are no member variables, there are no member functions.
Only functions and local variables, aside from the variables declared as per normal procedual programming.
What is an object?
It is an instance of a class, where a class can be seen as a datatype containing a blueprint for data and methods to deal with the data.
As such, if the member variable is indeed initialized with a member function, it is available to the whole object.
I thought it wasnt unless declared explicitly, but I was wrong since your original example showed otherwise.
Use:
class myClass
{
var $value = 0; #<-setting the member to zero
function setValue($value)
{
$value = $value * 2;
}
function getValue()
{
echo $this->value;
}
}
$obj = new myClass();
$obj->setValue($attrib = 2);
$obj->getValue();
No more member variable initialized in setValue()
Suddenly, $obj->getValue() outputs 0
I dont even have to test to be certain of that.