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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:35:49+00:00 2026-05-25T16:35:49+00:00

class Api_X_Y { private $_id; private $_blah_title; private $_XXXX; private static $inputParam; if($inputParam){ }

  • 0
class Api_X_Y {
    private $_id;
    private $_blah_title;
    private $_XXXX;
    private static $inputParam;

    if($inputParam){


    }
// Store the single instance of Api_X_Y
private static $Instance;

// Private constructor to limit object instantiation to within the class
private function __construct($id) 
{ 
    echo "Test <br />\n"; 
}

// Getter method for creating/returning the single instance of this class
public static function getInstance($id)
{
    if (!self::$Instance)
    {
        self::$Instance = new self($id);
    }

    return self::$Instance;
}


    public function resetInstance()
    {
           $this -> _id =NULL;
           $this -> _blah_title =NULL;
           $this -> _XXXX = NULL;

    }

}

?>

Ok I would like to modify the code so that when a new object with a new id comes in, it gets compared with inputParam( which is the ID of the old object), and if it is not the same it gets reset of the properties (public function resetInstance).
I’ve started by inserting the public function resetInstance and I know that I have to implement an IF statement somehow…..
Can anyone help me out?

  • 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-25T16:35:50+00:00Added an answer on May 25, 2026 at 4:35 pm

    You want a singleton, but you want it to return a new class when an ID differs. What’s the use of a singleton here?

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

Sidebar

Related Questions

I'm using the Facebook API and the class produces this object. object(User)#4 (5) {
class Foo { static bool Bar(Stream^ stream); }; class FooWrapper { bool Bar(LPCWSTR szUnicodeString)
I am providing Settings of my JAVA project in a Prefs.java class with static
I'm searching a lightweight API (preferable single class) to convert a Map<String,String> map =
I'm using a Google Analytics API Class in PHP made by Doug Tan to
I think I'm using the Users API incorrectly: class BaseHandler(webapp.RequestHandler): user = users.get_current_user() def
Recently, I've released an open-source class - wrapper of API functions available from one
According to the class ElementType in the API, you can annotate local variables and
I am trying to place API variables on ONE class file or mxml file
I am writing an Objective-C class but it uses an API written in C.

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.