problem with class properties not holding their value
Posted: Tue May 29, 2007 8:30 am
I'm stuck on this one, and I don't know why, maybe it has something to do with PHP 5 (I've written for 4 before).
when I create an object and set the value of a particular class property, it changes all the properties. I'm sure it's something simple, but I just don't get it.
thanks in advance.
-Brandon
when I create an object and set the value of a particular class property, it changes all the properties. I'm sure it's something simple, but I just don't get it.
Code: Select all
//---CREATE PROJECT-------
class pObject{
var $name;
var $start_date;
var $summary;
}
$test_pro = new pObject; //---- create the object
$test_pro->$name = "test name"; //----- set the project name property
echo $test_pro->$name; //----- returns "test-name"
$test_pro->$start_date = "date"; //----- set the project start date property
echo $test_pro->$start_date; //----- returns "date"
echo $test_pro->$name; //----PROBLEM also returns "date"
echo $test_pro->$summary; //----PROBLEM 2 this also returns "date" (as upposed to NULL)-Brandon