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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:19:33+00:00 2026-06-17T10:19:33+00:00

For some reason I cannot get static variables to be inherited in child classes.

  • 0

For some reason I cannot get static variables to be inherited in child classes. The following snippet seems ok, but does not work.

abstract class UserAbstract {
    // Class variables
    protected $type;
    protected $opts;
    protected static $isLoaded = false;
    protected static $uid = NULL;

    abstract protected function load();
    abstract protected function isLoaded();
}


class TrexUserActor extends TrexUserAbstract {
    // protected static $uid;  // All is well if I redefine here, but I want inheritance
    /**
     * Constructor
     */
    public function __construct() {
        $this->load();  
    }

    protected function load() {
        if (!$this->isLoaded()) {
            // The following does NOT work. I expected self::$uid to be available...
            if (defined(static::$uid)) echo "$uid is defined";
            else echo self::$uid . " is not defined";  

            echo self::$uid;
            exit;

            // Get uid of newly created user
            self::$uid = get_last_inserted_uid();

            drupal_set_message("Created new actor", "notice");
            // Flag actor as loaded
            self::$isLoaded = true;

            variable_set("trex_actor_loaded", self::$uid);
        } else {
            $actor_uid = variable_set("trex_actor_uid", self::$uid);
            kpr($actor_uid);
            exit;
            $actor = user_load($actor_uid);
            drupal_set_message("Using configured trex actor ($actor->name)", "notice");  
        }
    }
}

Aside from the possible copy-paste/reformat errors, the above code does not have the parent`s static variables, so I guess I am missing a detail somewhere.

Any clue on what is happening is appreciated.

  • 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-17T10:19:34+00:00Added an answer on June 17, 2026 at 10:19 am

    defined only applies to constants. You should be using isset

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

Sidebar

Related Questions

I have a search setup inside a div but for some reason cannot get
This is kind of embarrassing but I cannot for some reason get his CSS
I'm trying to get video thumbnails from Vimeo, but for some reason, I cannot
This is such a simple problem but for some reason I cannot get my
I am trying to get a class working but for some reason I cannot
I use CSS transitions fairly regularly and for some reason I cannot get them
For some reason I cannot seem to get a ko.computed observable to compute when
I'm developing http://pizzli.com/darrenwp as a WordPress Theme. For some reason, I cannot get the
I want to use http://msdn.microsoft.com/en-us/library/aa370654%28VS.85%29.aspx in my code. But for some reason I cannot
It's a common problem, solved many times, but for some reason i cannot find

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.