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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:47:17+00:00 2026-06-07T05:47:17+00:00

I am wondering if PHP will re-use the Parent class. With the following code:

  • 0

I am wondering if PHP will re-use the Parent class. With the following code:

// File parent.php
class Parent {
  $public foo = '';

  public function __construct($args) {
    // ..
  }

  // .. some functions
}

// File child1.php
class Child1 extends Parent {
  public function __construct() {

  }

  // .. Some overridden function
  // .. some extra functions
}

// File child2.php
class Child2 extends Parent {
  public function __construct() {

  }

  // .. some extra functions
}

Now to use either Child1 or Child2 you need to include the parent.php and childN.php. If I only use Child1 I can imagine they are somehow concatenated into a single being. However if I use Child2 on the same page.. would I get 2 ‘concatenated’ beings, that gobble on memory or is PHP super smart and able to see this and only use/load/whatever the Parent only once.

This example is pretty simplified, but the Parent is pretty big and there are plenty of children!

  • 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-06-07T05:47:18+00:00Added an answer on June 7, 2026 at 5:47 am

    Short answer is “PHP super smart”, the memory is only going to be used to store the class instances, the portion of memory to store the class definitions is negligible. You can also worry about number of inclusions, but in this particular case everything is far from slow.

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

Sidebar

Related Questions

I'm wondering what the PHP equivalent to this code is: require zlib foo =
I'm wondering if this kind of thing will ever be possible in PHP (and
I am wondering if php methods are ever defined outside of the class body
I am wondering if there a function in php that can allow me put
Ok, just wondering on the versions of PHP that this class is built into.
I'm wondering how can I use Lucene for searching and indexing with PHP, Google
Ok. I have my query written finally for my php file (which will write
I'm wondering if anyone knows of a PHP setting that will automatically escape double
although i use foreach and while, i was wondering if using the for(i=0;i<varlength;i++) will
Wondering if I could get some advice on tokenizing a string in php since

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.