Re: should basic data validation go outside a function or inside?
| From: | Sebastian Mendel | Date: | Thu, 11 Nov 2004 13:09:55 +0000 |
| Subject: | Re: should basic data validation go outside a function or inside? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201757@lists.php.net to get a copy of this message | ||
Brad Pauly wrote:
yes, and of course shouldnt every function check it parametres before proceeding? -- Sebastian Mendel www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheetshould basic data validation come before a function call or be performed within the function?I would do the validation inside the function. This avoids repeating the validation everywhere the function is called. It also makes the function more self-contained. It expects a certain input and complains, or returns false, if it doesn't get it.