note 12591 deleted from language.variables.variable by philip
| From: | philip@php.net | Date: | Wed, 16 Mar 2005 01:35:06 +0000 |
| Subject: | note 12591 deleted from language.variables.variable by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86511@lists.php.net to get a copy of this message | ||
Note Submitter: isis at frostbyte dot fdt dot net
----
I don't know if this has been mentioned before, but I found an interesting use of variable
variables. They are great for checking required (especially when you have about 15 of them). You
create an array with the required variable names from the form and then loop through the array
checking for blanks, NULLS, etc.
ex.
<?php
$required = array("username", "password");
for ($i = 0; $i < count($required); $i++)
{
if (($$required[$i] == "") || (!$$required[$i]))
{
echo ("Umm... we need $$required[$i]");
}
}
exit();
?>
Just a thought if you have large forms. Still need to figure out how to get it to work with
mutliple input variables (although it should, I have never tried).
frostbytten