UrbanDweller Posted May 19, 2012 Share Posted May 19, 2012 Hey, In my script I am currenlty working on I have 2 classes one which calls the second in the hope it will return a value to it but doesnt send the variable back. The example code below give you and idea of what I am looking for as my script it too long to add. class oneClass{ function bar(){ $var1 = "test" $two = twoClass(); $result = $two->foo($var1); echo $result; } } class twoClass{ function foo($var1){ $result = $var1 . ' is successful!'; $this->fooTwo($result); } function fooTwo($result){ $result = $result . ' Pass me back now?'; return($result); //Want to pass the variable back to "oneClass->bar();" } } // Starts script $testme = new oneClass(); $testme->bar(); This is a very simple example but states what i am wanting to. Any ideas would be much appreciated! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/262760-variable-wont-return-from-between-classes/ Share on other sites More sharing options...
smoseley Posted May 19, 2012 Share Posted May 19, 2012 in oneClass::bar: $two = new twoClass(); and in twoClass::foo: return $this->fooTwo($result); Quote Link to comment https://forums.phpfreaks.com/topic/262760-variable-wont-return-from-between-classes/#findComment-1346752 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.