PHP Array and Class problem

Started by
1 comment, last by Rankith 18 years, 2 months ago
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?
To aid and protect, Thus honor.
Advertisement
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]){
_____________________#define ever (;;)for ever delete (void *) rand();
Thanks, that worked great. Silly me.
To aid and protect, Thus honor.

This topic is closed to new replies.

Advertisement