0
我想在Codeigniter模型中创建重载方法。我知道方法重载不支持像JAVA的PHP。所以我想知道哪一个是从以下两个做到这一点最好的办法还是请建议是否有任何其他正确的方式如何在codeigniter模型中使用方法开发
function mymethod($p1 = null, $p2 = null){
if (isset($p1)){
echo "My method has 1st parameter<br>";
}
if (isset($p2)){
echo "My method has 2nd parameter also";
}
rest code..
}
OR
public function __call($m , $p)
{
switch($m)
{
case "mymethod":
$count = count($p);
switch($count)
{
case "0":
return "You are passing 0 argument";
break;
case "1":
return "You are passing 1 argument";
break;
case "2":
return "You are passing 2 parameter";
break;
case "3":
return "You are passing 3 parameter";
break;
default:
throw new exception("Bad argument");
}
default:
throw new exception("Function $m does not exists ");
}
}