I need some help. How do I return a variable from an linked class instead of echo/printing the value from inside the class? Ok check out my example:
---- test.obj ----
class testOOP
{
function doSomethin($var)
{
if($var > 1)
{
$this->msg = "Say Somethin";
//increase the value of variable
$var++;
}
else
{
$this->msg = "Give Error";
}
//echo results to calling page
echo $msg;
}
}
---- test.php ----
<?
include("pathto/test.obj");
if(isset($HTTP_POST_VAR["var1"])
{
$testFunction = new testOOP();
$testFunction->doSomethin($var);
}
else
{
redirect blah blah blah
}
?>
I want to return $msg variable from my class rather than echo my value. I want to be able to use my variable value to modify other functions and variables.
Anyways, thanks 🙂