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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:21:31+00:00 2026-05-25T17:21:31+00:00

I am working on some legacy code at the moment and stumbled across a

  • 0

I am working on some legacy code at the moment and stumbled across a weird class/function call that php.net doesn’t seem to explain and I’ve never seen before:

if(security::instance()->check_client()) {

There is a class security, and there are functions named instance and check_client inside that class. But this seems to call two functions in one statement and pass the one to the other, or at least thats what the outcome suggests.
Can someone clarify this one for me?

  • 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-25T17:21:31+00:00Added an answer on May 25, 2026 at 5:21 pm

    This is a classical implementation of the singleton pattern

    I suppose your class security looks like this :

    class security {
        private static $instance = null;
    
        private function __construct() {}        
    
        public static function instance() {
            if (null === self::$instance)
                self::$instance = new security();
    
            return self::$instance;
        }
    
        public function check_client() { /* do something */ }
    }
    

    What it does is that the static method instance returns an instance of the class security; Which mean that security::instance() instanceof security === true

    That’s why you can chain the call to the check_client() method as in your exemple

    security::instance()->check_client()
    

    This is similar to

    $secu = security::instance();
    $secu->check_client();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on some legacy code and have come across something that I'm
I'm working with some legacy code and I came across a function which is
I am working on some legacy PHP code that holds a ton of in-line
We are working with some legacy code that accesses a shared drive by the
I have been working on some legacy C++ code that uses variable length structures
I have some really complicated legacy code I've been working on that crashes when
Working in some legacy code, I've run across a ton of Try/Catch statements. Try/Catch
I'm working with some legacy code that has an import like so: #import C:\Program
I'm working updating some legacy code that does not properly handle user input. The
For the past year I've been working on some legacy code that was written

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.