note 41238 added to function.is-callable
| From: | webmaster__AT__digitalanime__DOT__nl at rn2 dot php dot net | Date: | Sat, 03 Apr 2004 19:30:23 +0000 |
| Subject: | note 41238 added to function.is-callable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67591@lists.php.net to get a copy of this message | ||
<?php
while(list($key,$value)=each($HTTP_POST_VARS))
{
$tmpVar = 'return isset($' . 'this->' . $key . ');';
if(is_callable($key) && eval($tmpVar) && trim($value) != "")
{
$tmpSet = '$this->set' . ucfirst($key) . "('" . $value .
"');";
eval($tmpSet);
}
}
?>
Why do you use this?
Isn't this a better solvation (or.. Whatever :P)
<?php
foreach($_POST as $key => $value)
{
if(is_callable($key) && isset($this->{$key}) && trim($value != '')
{
$this->{'set' . ucfirst($key)}($value);
}
}
?>
Tada.. Variable objects, that's what they are..
----
Manual Page -- http://www.php.net/manual/en/function.is-callable.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41238
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41238&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41238&report=yes
Search -- http://master.php.net/manage/user-notes.php