Üst sınıf php method_exists

0 Cevap php

Ben php fonksiyon method_exists kullanmaya çalışıyorum, ama ben yöntemi, bir nesnenin ana sınıfında olup olmadığını kontrol etmeniz gerekir.

bu yüzden:

class Parent
{
    public function myFunction()
    {
        /* ... */
    }
}

class Child extends Parent
{
    /* ... */
}

$myChild = new Child();

if (method_exists($myChild, 'myFunction'))
{
    /* ... */
}

if (method_exists(Parent, 'myFunction'))
{
    /* ... */
}

if (is_callable(array('Parent', 'myFunction'))
{
    /* ... */
}

Ama yukarıdaki hiçbiri çalışıyoruz. Ben sonraki denemeye ne emin değilim.

Herhangi bir yardım için teşekkür ederiz!

0 Cevap