Novice question but then I am a novice at this...
I have a class for registering users and I have functions for different validation. Basically, I run "mainTest" which pulls in the variables from a form and then runs each function (test1, test2). Within those functions if something doesn't validate within the function I set a variable called $error to true. What I am trying to do within the "mainTest" function check if the variable $error has been set to true in any of the other functions do something but when I echo the $error variable it just says null i.e. the functions aren't linking. (trying not to use Global Variables).
Any Ideas here is an example of how I am doing this...
class myClass {
private function test1($var1, $var2) {
if....
else {
$error = true;
return $error;
}
}
private function test2($var3, $var4) {
if....
else {
$error = true;
return $error;
}
}
public function mainTest($var1, $var2, $var3, $var4) {
$this->test1($var1, $var2);
$this->test2($var3, $var4);
if ($error == true) {
//do something
}
}
}
class myClass
and use it in the following way$this->error
(php.net/manual/en/language.oop5.basic.php) – adamj May 9 at 4:02$error
as an instance variable. – Ja͢ck May 9 at 4:02