Jump to content

Variable wont return from between classes


UrbanDweller
 Share

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

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.