consecutive if's in PHP

Question!

I'm doing some validation now in PHP, and I'm running allot of conditional statements, for example:


if ($this->email->isValid($email))
return false;
if ($this->username->isValid($username))
return false;

ect..

Is there a nice way to do this? Or do I just run ten If statements like the ones above? I can't use switch obviously, but I'm looking for that type of solution..

P.S... I'm using Zend Framework for validation



Answers

If this is data from a form, take a look at Zend_Form, as recommended by a poster in your other question

I posted some example code which details adding validators to form elements



Just make sure that you put the most obvious validation at the top, so if its going to fail it will trip before it runs through every statement. Also, I don't like if statements without curly brackets, but then thats just a matter of opinion.

By : Christian


if ($this-


This video can help you solving your question :)
By: admin