Re: class Problem
| From: | Scott Houseman | Date: | Tue, 17 Sep 2002 11:37:38 +0000 |
| Subject: | Re: class Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116618@lists.php.net to get a copy of this message | ||
Hi there.
Try doing it this way:
You need to access the class's variable using the $this identifier
e.g.
class MenueItem {
var $ID_Menue;
var $Name;
var $Parent_ID;
var $Next_ID;
var $Prev_ID;
function Write() {
echo "Parent_ID: " . $this->Parent_ID . "<BR>";// Not $MI
//(no output at all!)
}
Regards
-Scott
David Eggler wrote:
I create a Instance fo the Class MenueItem in Menue. I change the value of one of its variables. But when i call the function within MenueItem there seems not to be a value: The intresting thing is it works with Other variables, even i cant echo them, they have a value.... Thanks for help class Menue {-- //--------------------------------------------// // Scott Houseman // // Jam Warehouse http://www.jamwarehouse.com/ // // Smart Business Innovation // // +27 21 4477440 / +27 82 4918021 // //--------------------------------------------//function Makechilde($somvalue) {echo "Next_ID: " . $Parent_ID . "<BR>"; //Works $MI->Parent_ID = $Parent_ID; echo "Parent_ID: " . $MI->Parent_ID . "<BR>";//correct output $MI->write(); } } class MenueItem { var $ID_Menue; var $Name; var $Parent_ID; var $Next_ID; var $Prev_ID; function Write() { echo "Parent_ID: " . $MI->Parent_ID . "<BR>";//(no output at all!) }}