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 Quote 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 } } ?> Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.