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 6132213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:04:25+00:00 2026-05-23T17:04:25+00:00

How do I call child function from parent static function ? In php5.3 there

  • 0

How do I call child function from parent static function ?

In php5.3 there is a built in method called get_called_class() to call child method from parent class. But my server is running with php 5.1.

Is there any way can do this ?

I want to call it from a static function . So that I can not use “$this”

So i should use “self” keyword.

Below example my parent class is “Test123” , from the parent class static function “myfunc” am trying to call child class function like this “self::test();”

abstract class Test123
{

  function __construct()
  {
    // some code here
  }

  public static function myfunc()
  {
    self::test();
  }

  abstract function test();
}

class Test123456 extends Test123
{
  function __construct()
  {
    parent::__construct();
  }

  function test()
  {
    echo "So you managed to call me !!";
  }

}

$fish = new Test123456();
$fish->test();
$fish->myfunc();
  • 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-23T17:04:26+00:00Added an answer on May 23, 2026 at 5:04 pm

    Edit: What you try to achieve is not possible with PHP 5.1. There is no late static bindings PHP Manual in PHP 5.1, you need to explicitly name the child class to call the child function: Test123456::test(), self will be Test123 in a static function of the class Test123 (always) and the static keyword is not available to call a static function in PHP 5.1.

    Related: new self vs new static; PHP 5.2 Equivalent to Late Static Binding (new static)?


    If you are referring to a static parent function, then you need to explicitly name the parent (or child) for the function call in php 5.1:

    parentClass::func();
    Test123456::test();
    

    In PHP 5.3 you can do this instead with the static keyword PHP Manual to resolve the called class’ name:

    static::func();
    static::test();
    

    If those are non-static, just use $this PHP Manual:

    $this->parentFunc();
    $this->childFunc();
    

    Or if it has the same name, use parent PHP Manual:

    parent::parentFunc();
    

    (which is not exactly what you asked for, just putting it here for completeness).

    Get_called_class() has been introduced for very specific cases like to late static bindings PHP Manual.

    See Object Inheritance PHP Manual

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How is the correct way to call a child class method from a parent
How do i call a function of a child class from parent class? Consider
is it possible in c++ to call a child function from a parent function.
How do I call the parent function from a derived class using C++? For
I have a static function in a class that needs to be called from
Is it possible to call a child function from within the parent? I know
I want a pure virtual parent class to call a child implementation of a
If I need to call a specific function in the parent application from a
I tried to call from child object a parent attribute var parentObj = {
I notice sometimes with my parent/child objects or many-to-many relationships, I need to call

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.