function (func,tag1,tag1){
if func="top" 我调用函数 top
elseif func="foot" 我调用函数 foot
}
function top(tag1,tag2){
...
}
functin foot(tag1,tag2){
}
这样的函数该如何去写
if func="top" 我调用函数 top
elseif func="foot" 我调用函数 foot
}
function top(tag1,tag2){
...
}
functin foot(tag1,tag2){
}
这样的函数该如何去写
<?php
function sel($func,$tag1,$tag2){
$func($tag1,$tag2);
}function top($tag1,$tag2){
echo "top me!".$tag1;
}function foot($tag1,$tag2){
echo "foot u!".$tag2;
}
sel('top',123,456);
sel('foot',123,456);
?>
</pre>
<pre>
<?php
function sel($num,$tag1,$tag2){
$cls = 'top'.$num;
$newcls = new $cls();
$newcls->top($tag1,$tag2);
}
class top1
{
public function top($tag1,$tag2){
echo "top me!".$tag1;
}
}class top2
{
function top($tag1,$tag2){
echo "top u!".$tag2;
}
}
sel(1,123,456);
sel(2,123,456);
?>
</pre>