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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:29:44+00:00 2026-06-17T21:29:44+00:00

From the php documentation,we access global classes like <?php namespace A\B\C; class Exception extends

  • 0

From the php documentation,we access global classes like

<?php
namespace A\B\C;
class Exception extends \Exception {}
$a = new Exception('hi'); // $a is an object of class A\B\C\Exception
$b = new \Exception('hi'); // $b is an object of class Exception
$c = new ArrayObject; // fatal error, class A\B\C\ArrayObject not found
?> 

However,i am a lost when the doc says that

<?php
$a = new \stdClass;
?>

is functionally equivalent to:

<?php
$a = new stdClass;
?>

here http://php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.shouldicare

Can someone kindly explain what the doc is saying here.

Thanks.

  • 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-17T21:29:45+00:00Added an answer on June 17, 2026 at 9:29 pm

    Right above those two code examples in the docs is the important heading:

    If I don’t use namespaces, should I care about any of this?

    No. Namespaces do not affect any existing code in any way, or any as-yet-to-be-written code that does not contain namespaces. You can write this code if you wish:

    So the implication here is not that you can write new stdClass; inside a namespace and have it be equivalent, but rather that if you are not using namespaces at all, then you needn’t worry about the backslash new \stdClass;

    When working in a namespace, the rule does apply and you will need to use new \stdClass;.

    And this doesn’t just apply to the generic stdClass, but to any class.

    // Without namespaces:
    $mysqli = new MySQLi(...);
    
    // With namespaces
    $mysqli = new \MySQLi(...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am from PHP and now using Django, I like match against queries of
I created an object from PHP with json encode, but I am having difficulty
Quote from the PHP documentation on overloading : It is not possible to use
I am trying to get access to SocialCast's API from PHP. They have just
Coming from PHP with some Java Struts 2.0 experience any tips/tricks on learning GWT?
Anonymous functions are available from PHP 5.3 . Should I use them or avoid
I came from PHP language(codeigniter), but now I learning ASP.Net MVC :) In PHP
I got this from php.net website. This is related to the problem I am
I came to ruby from PHP. How could i do the next thing in
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']

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.