본문 바로가기

프로그래밍 언어

[PHP] __call() 사용법

※ 이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.




예제


<?php

class dog

{

//public function meow(){

// print "Dogs don't meow!\n";

//}


public function __call($function, $args)

{

$args = implode(', ', $args);

print "Call to $function() with args '$args' failed!\n";

}

}


$poppy = new dog();

$poppy->meow("foo", "bar", "baz");

?>



결과 --


Call to no() with args 'foo, bar, baz' failed!