Ok, I do have some questions.
1)You create constants so you can call them statically from the main script. Then pass them as arguments in the
isValid() function. How are you able to pass in extra arguments when it's not defined in the function? Or does PHP loosely allow you to add optional arguments without have to specify them when creating the functions? And if so, does this work for regular functions too or just class methods?
2)
$bValidated is set to
false. Why do we do this? Is this because we have to declare every property in the class before using it?
3) array_shift($aArgs). Since in your example, you passed 3 arguments to the isValid function and then do a foreach loop on the array $aArgs, are you shifting to the 2nd element so that the foreach starts from there, so basically all we get are the 2 constants: NOT_EMPTY and IS_EMAIL....?
4) After checking if a method exists, I'm a little unclear on what we do here. We set:
$bValidated = $this->$szFunction($szVariable);
I don't see any methods called:
$szFunction, so I'm not sure what is going on here.
5) We then do this:
PHP Code:
if(!$bValidated) { return false; }
But since further up, we already declare
$bValidated as
false, wouldn't putting a negation operator convert it to true?
6) Since the other methods are set to private. Is the
isValid method basically our "getter" method?