note 18964 added to functions.variable-functions
| From: | tboothby at t dot chek dot com | Date: | Mon, 11 Feb 2002 23:28:55 +0000 |
| Subject: | note 18964 added to functions.variable-functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26489@lists.php.net to get a copy of this message | ||
I don't see many people getting much use out of this feature; so I'll put an example up.
I use this for modifying data in rows retrieved from a database, customizing outputs, etc.
<?
function test_1($var) {
if($var%3)
return $var;
else
return 0;
}
function test_2($var) {
if($var<25)
return 25+($var%5);
else
return $var*2;
}
function test_3($var) {
if($var>30)
return $var+16;
else
return $var-16;
}
function test_4($var) {
if($var&459)
return $var|255;
else
return $var&255;
}
mt_srand(time());
$n=mt_rand(0,9000);
for($i=1;$i<5;$i++) {
$func="test_$i";
echo $func($n)."\n";
}
?>
--
http://www.php.net/manual/en/functions.variable-functions.php
http://master.php.net/manage/user-notes.php?action=edit+18964
http://master.php.net/manage/user-notes.php?action=delete+18964
http://master.php.net/manage/user-notes.php?action=reject+18964