GuitarGod Posted October 17, 2008 Share Posted October 17, 2008 Hi all, I'm in need of some help. I want to know how I can pass information between functions as part of a class. <?php class Whatever { // function whatever has a variable function Whatever( $variable ) { return $variable; } // I need to get that variable into this function, how?? function AnotherFunction() { echo $this->Whatever; // ?? } } ?> Thanks for any help Link to comment https://forums.phpfreaks.com/topic/128842-solved-php-class-passing-information-between-functions/ Share on other sites More sharing options...
MadTechie Posted October 17, 2008 Share Posted October 17, 2008 try this <?php class Whatever { private $ten = 10; // function whatever has a variable function Whatever( $variable ) { return $variable + $this->ten; } // I need to get that variable into this function, how?? function AnotherFunction() { echo $this->ten; } function YetAnotherFunction() { $this->ten = 5; //LOL } } ?> Link to comment https://forums.phpfreaks.com/topic/128842-solved-php-class-passing-information-between-functions/#findComment-667923 Share on other sites More sharing options...
GuitarGod Posted October 17, 2008 Author Share Posted October 17, 2008 Worked a treat Thanks a lot Link to comment https://forums.phpfreaks.com/topic/128842-solved-php-class-passing-information-between-functions/#findComment-667928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.