I suddenly thought of it today and wrote a piece of code to test the php function.
// 待测试的函数
function Test($Param1, $Param2, $Param3)
{
return $Param1 . "|" . $Param2 . "|" . $Param3;
}
/**
* Automatic test
*
* @param string $FunctionName Function name
* @param array $ParamList Parameter list
* @return array
*/
function sysTestFunction($FunctionName, $ParamList)
{
if(empty($FunctionName))
{
echo "The function name cannot be Is empty";
return false; ;
}
$TestParamList = sysCombineArray($ParamList);
echo "Start test function" . $FunctionName . "
";
foreach($TestParamList as $Key = >
${"Param" . $ParamKey} = $Param; {
echo "& lt;";
Print_r ($ param);
}
Elseif (is_Bool ($Param))
{
echo "true";
else String or number: ";
echo $Param; empParamList);
unset($TempParamList);
eval("$TestReturnResult = " . $FunctionName . "(" . $Params . ");");
if(is_array($TestReturnResult))
{
using using using using use using through through out through out through out out through out’s'''' through' ‐ to ‐ ‐‐‐‐‐‐‐ ‐ echo "Function return array: ";
elseif(is_bool($TestReturnResult))
{
🎜> }
🎜> since turnResult;
}
echo "
";
}
}
/**
* Function to calculate combination
*
* @param array $CombinList 2-dimensional array to be arranged and combined
* @return array The combined array
*/
function sysCombineArray($CombinList)
{
if(!is_array(current($CombinList)))
{
echo "The parameter is not a 2-dimensional array";
return false;
}
/* Calculate C(a,1) * C(b, 1) * ... * Value of C(n, 1) */
$CombineCount = 1;
foreach($CombinList as $Key => $Value)
{
$CombineCount *= count($Value);
}
$RepeatTime = $CombineCount;
foreach($CombinList as $ClassNo => $ParamList)
{
/ / The maximum number of vertical repetitions of the elements in $ParamList after splitting into combinations
through $ParamList $StartPosition $RepeatTime $ParamList Param)
; SpaceCount ; $J ++)
{
for($I = 0; $I < $RepeatTime; $I ++)
{
$Result[$T empStartPosition + $I][$ ClassNo] = $Param;
tTime;
}
}
Return $Result;
}
?>
http://www.bkjia.com/PHPjc/825193.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/825193.html
TechArticle
I suddenly thought of it today and wrote a piece of code to test the php function. Copy the code The code is as follows: ?php /** * Parameter array $ParamList description * * The first dimension index of the array is the function that needs to be tested...