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

  • Home
  • SEARCH
  • 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 6167385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:30:08+00:00 2026-05-23T22:30:08+00:00

I encountered a PHP class written by a previous employee that is defined like

  • 0

I encountered a PHP class written by a previous employee that is defined like this:

namespace SomeNamespace;

class SomeClass extends ::SomeClass
{
    private function __construct() {}

    public static function someFunction()
    {
        //Do something
    }
}

Would somebody please explain what is going on here? Is this class extending itself? I know a singleton would use a private constructor, but not sure that is what is happening here.

The actual class has to do with caching. Not sure if that helps.

  • 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-23T22:30:08+00:00Added an answer on May 23, 2026 at 10:30 pm

    I don’t think you can do this kind of thing using :: ; but it should work if you are using the namespace separator : \

    I just tested with PHP PHP 5.3.5 — and using :: does indeed get me an error.

    Using \, on the other hand, works just fine (see example below).

    For example, being in the global namespace (outside of any specific namespace) you could define a class SomeClass :

    namespace {
    
        class SomeClass
        {
            public function method() {
                var_dump("child: " . __METHOD__);
            }
        }
    
    
        $obj = new SomeNamespace\SomeClass();
        $obj->method();
    
    }
    

    And, in a specific namespace called SomeNamespace in my example, you could define a class SomeClass that would extend the class from the global namespace — which is accessible as \SomeClass :

    namespace SomeNamespace {
    
        class SomeClass extends \SomeClass
        {
            public function method() {
                var_dump("parent: " . __METHOD__);
            }
        }
    
    }
    

    Sidenote : Here, I’ve use the bracketed syntax, as I’m putting the two portions of code in the same file (see Example 3 on that manual page) — but it should work just the same with several files.


    Note that with the first alpha versions of PHP 5.3, the namespace separator was not \, but ::

    So, if you are using PHP 5.3 alpha 1 or 2 (and maybe 3, not sure if \ has been choosen before or after alpha 3), using :: might work.

    (Of course, you should not be using an alpha — especially considering that there have been stable versions of PHP 5.3 for two years now)

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

Sidebar

Related Questions

We're currently running with php 5.2.5. We have now encountered a bug that creates
This is my Welcome controller class Welcome extends MY_Controller { function __construct() { parent::__construct();
Model : <?php class Blogm extends CI_Model{ function __construct() { // Call the Model
I have a callback function for CURLOPT_PROGRESSFUNCTION in codeigniter like below: class download_model extends
I have encountered this error Fatal error: Class 'PHPExcel_Shared_ZipStreamWrapper' not found in \VBOXSVR\ACACIASOFT\apc\spreadsheet\lib\phpexcel\PHPExcel\Autoloader.php on
I encountered the following ddl in a pl/sql script this morning: create index genuser.idx$$_0bdd0011
I encountered a problem when running some old code that was handed down to
I encountered this term Hindley-Milner , and I'm not sure if grasp what it
I'm running a third party script by using a wrapper class I've written which
I've encountered a very odd issue in a class I'm creating. Here is a

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.