eldan88 Posted May 20, 2014 Share Posted May 20, 2014 (edited) Hey Guys. I am trying to assign a property through a method that is called in a swtich method. After the property gets "assigned" I do a var_dump on the property and it returns NULL? I am not sure why it returns NULL.... I would really appreciate any help... class Tea { public $current_tea; //Current tea does not get assigned when using the AssignTea($TeaArg) function private $upcoming_tea = "Blacktea"; public function SelectTea() { $TeaType = "Black"; switch ($TeaType) { case "Black": $this->AssignTea($this->upcoming_tea); break; }// End of Swtich }// End of function SelectTea() private function AssignTea($TeaArg){ $this->current_tea = $TeaArg; } } $tea = new Tea(); var_dump($tea->current_tea); Edited May 20, 2014 by eldan88 Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted May 20, 2014 Share Posted May 20, 2014 You need to call the SelectTea method first, which then calls the AssignTea method, which then sets the value for the current_tea property $tea = new Tea(); $tea->SelectTea(); var_dump($tea->current_tea); Quote Link to comment Share on other sites More sharing options...
eldan88 Posted May 20, 2014 Author Share Posted May 20, 2014 Wow. That's right.. how did I forget that! Thanks alot Ch0cu3r! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.