0
Codeigniter의 모델에서 오버로드 메서드를 만들려고합니다. 메서드 오버로드가 JAVA 같은 PHP에서 지원되지 않는다는 것을 알고 있습니다. 그래서 내가 다른 올바른 방법이 방법은codeigniter 모델에서 메서드 oveloading을 사용하는 방법
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..
}
또는
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 ");
}
}