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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:54:45+00:00 2026-05-28T03:54:45+00:00

I was just wondering if the next situation could be possible or not, I’ve

  • 0

I was just wondering if the next situation could be possible or not, I’ve read the PHP Manual documentation, but I would like another perspective because it’s not so clear for me.

So I have for example one class:

class SomeClass {
    public function someFunction() {
        ...
    }
}

And an extension of it:

class Extension extends SomeClass {
    public function someOtherFunction() {
        ...
    }
}

My question is, could I be able to use the public functions inside the classes on both ways, the main class’s function inside the extended function and the other way around?

And would I be doing that how?

  • 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-28T03:54:46+00:00Added an answer on May 28, 2026 at 3:54 am

    You can use the public and protectedfunctions of your parent in the extended (child) class:

    class Extension extends SomeClass
    {
        public function someOtherFunction() {
            $foo = $this->someFunction(); // from parent class
            return $foo;
        }
    }
    

    When class “Extension” is created, its basically a copy of “SomeClass” which you can modify in the way as you can add new functions or overwrite those of the parent class.

    The parent does not know about the Extension (it can be extended multiple times, eg “JSONRequest extends Request”, “XMLRequest extends Request”). Calling extended functions from within the parent makes no sense, since the parent class can never know which childs function it should call in such a situation. This type of Inheritance is one of the basic concepts of OOP and clear interfaces.

    In other words, no it will never work the other way round. And it should not.

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

Sidebar

Related Questions

Hello fellow Computer People! I could do this myself, but was just wondering if
Just wondering is it possible to build CLI app that can be run from
Just wondering what the best way to access read only information form a Microsoft
Possible Duplicate: Smooth text animation (Marquee) using WPF I am just wondering if there
I was just wondering how you can echo a range of dates in PHP
Hey Just wondering how the following can happen Object reference not set to an
I was just wondering, what would happen if key of a HashMap is mutable,
Just wondering when using the jQuery Cycle plugin if for the next/prev buttons, it
I was just wondering why the vbs code in the link below is not
I was just wondering if it was possible to delete an item from a

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.