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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:14:48+00:00 2026-06-05T00:14:48+00:00

I want to know is it possible to have a class that’s extended have

  • 0

I want to know is it possible to have a class that’s extended have a var set and used from the base class?

eg:

class me
{
    public $hello = array();

    protected function setter($me)
    {
        $this->hello[] = $me;
    }
}

class foo extends me
{
    public function __construct()
    {
        $this->setter('foo');
    }
}

class yoo extends me
{
    public function __construct()
    {
        parent::setter('yoo');
    }
}

$me = new me();
$foo = new foo();
$yoo = new yoo();

print_r($me->hello);

the array printed is array() nothing is set.

  • 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-05T00:14:50+00:00Added an answer on June 5, 2026 at 12:14 am

    Yes, you can do this by making $hello static:

    public static $hello = array();
    

    In doing so, you will have to drop the $this from $this->hello[] = $me; and replace it with a self, as hello will not longer be unique to the current object instance:

    self::$hello[] = $me;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know whether it is possible to have multiple stores under 1
So what I want to know is whether the following is possible. I have
Hello I want to know if is possible to modify a cube dimension in
Let's say I have a class that has 3 properties. I don't know which
I have a class that reads a pop3 email server. I want to write
I have a class extends ViewGroup and want to get every MotionEvent from it.
I have a small class that holds two strings as follows: public class ReportType
I just want to know if is possible to get the permission that a
Possible Duplicate: Intercept object on method invocation with Mockito I have an class that
I just wanted to know if it's possible to have 1 UIViewController class connected

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.