PHP Array and Class problem
Hi, I am having a problem using an array inside a class in php. Here is my class:
class Errors{
private $errors = array();
private $numErrors;
function __construct(){
$numErrors = 1;
$errors[1] = 1;
}
function Failed($fieldIn){
if($errors[1]){
return 'true';
}
else{
return 'false';
}
}
}
however, when I go to test that. The Failed function returns false... What am I doing wrong there?
private $errors = array();
private $numErrors;
is fine
but change all the rest of them to
$this->numErrors = 1;
$this->errors[1] = 1;
and
if($this->errors[1]){
private $numErrors;
is fine
but change all the rest of them to
$this->numErrors = 1;
$this->errors[1] = 1;
and
if($this->errors[1]){
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement