親ã¯ã©ã¹ã®ä¸ã§å°ã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ãããé¢æ°ãå¤æ°ã使ãããã¨ã
class parent { const test = 1; public function test() { echo self::test } } class child extends parent { const test = 2; } $hoge = new child; $hoge->test();
ã£ã¦ãã㨠1 ãåºåããã¡ããã
ããã 2 ãåºãããã¨ãã¯
class parent { const test = 1; public function test() { echo constant(get_called_class().'::test') } } class child extends parent { const test = 2; } $hoge = new child; $hoge->test();
ã£ã¦ãã£ã¦ããã㨠2 ãåºãã
å®æ°ãªã constant 使ãã°ããã
é¢æ°ãªã call_user_func 使ãã°OKï¼call_user_func(get_called_class().'::sendMail', $test)ããã¦æãï¼ã