Jump to content

Variable wont return from between classes


UrbanDweller

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.