Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3603498
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:52:47+00:00 2026-05-18T20:52:47+00:00

Having a little trouble with this static ‘inheritance’ in php 5.3 I need to

  • 0

Having a little trouble with this static ‘inheritance’ in php 5.3
I need to test if a static function exists in static class but I need to test it from inside a parent static class.

I know in php 5.3 I can use the ‘static’ keyword to sort of simulate ‘this’ keyword.
I just can’t find a way to test if function exists.

Here is an example:

// parent class
class A{

// class B will be extending it and may or may not have 
// static function name 'func'
// i need to test for it

    public static function parse(array $a){
        if(function_exists(array(static, 'func'){
            static::func($a);
        }
    }
}

class B extends A {
    public static function func( array $a ){
        // does something
    }
}

So now I need to execute B::parse();
the idea is that if subclass has a function, it will be used,
otherwise it will not be used.

I tried:

function_exists(static::func){}
isset(static::func){}

These 2 do not work.

Any ideas how to do this?
By the way, I know about the possibility to passing a lambda function as a workaround, this is not an
option in my situation.

I have a feeling there is a very simple solution that I just can’t think of right now.

Now I need to call

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:52:47+00:00Added an answer on May 18, 2026 at 8:52 pm

    You can’t use function_exists for classes and objects (methods), only functions. You have to use method_exists or is_callable. isset only works with variables. Also, static does not simulate $this, they are two completely different things.

    That being said, in that specific case, you have to use is_callable with a quoted static keyword:

    if (is_callable(array('static', 'func'))) {
        static::func();
    }
    

    or…

    if (is_callable('static::func')) {
        static::func();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble to achieve this little round robin project. What i
Having a little bit of trouble with this section of code: if(!empty($_POST['RemoveRequest']) && isset($_POST['RemoveRequest'])){
I am having a little bit of a trouble with the following: <script> $(document).ready(function()
I'm having a little trouble figuring out exactly how const applies in a specific
I'm fairly new to ASP.NET MVC, and I'm having a little trouble with scripts...
having a little architectural trouble here. In C++, we have the notion of 'friends,'
I'm having a little bit of trouble making a sticky form that will remember
I'm having a little bit of trouble understanding what the problem is here. I
I'm having a little problem with the following: When I execute this line: echo
I'm having a little trouble overloading methods in C#. I have two methods that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.