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 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); 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
Archived
This topic is now archived and is closed to further replies.