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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:26:49+00:00 2026-06-17T06:26:49+00:00

According to the php documentation http://php.net/manual/en/language.oop5.constants.php A property declared as static can not be

  • 0

According to the php documentation http://php.net/manual/en/language.oop5.constants.php

A property declared as static can not be accessed with an instantiated class object

But doesn’t the following example show that you can access a static property from the object $foo?

class Foo{
    static $my_static = 'foo';
    function staticValue(){
        return self::$my_static;
    }        
}

$foo = new Foo();
echo $foo::$my_static;
  • 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-17T06:26:51+00:00Added an answer on June 17, 2026 at 6:26 am

    The trick here is that you are using the scope resolution operator :: which always references the class. It doesn’t matter if you use $foo or $this or self.

    Self is a keyword in PHP that references the current level, but :: can be used on an object to gain reference to the class for that object. self:: is in the same family of keywords as parent::, think of self:: as wanting access to something at the current level of an object, and parent:: as wanting access to something below the current object.

    Therefore, to access something that is defined in the class. PHP created the :: operator. If you just need something from the class that is static, then you can use self inside the class or an object reference outside it.

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

Sidebar

Related Questions

According to one of the man pages http://www.php.net/manual/en/language.oop5.static.php : Calling non-static methods statically generates
According to PHP documentation, HttpResponse is a static class to manipulate the Http response
According to the PDO documentation , you can store database login details in php.ini,
According to PHP.net manual, pg_pconnect will create a persistent connection, or will return the
According to the PHP documentation: The overload() function will enable property and method call
According to php manual nor php://input neither $HTTP_RAW_POST_DATA work with multipart/form-data POST-requests. php://input allows
According to the PHP manual , the four variable types for mysqli->bind_param are integer,
According to the PHP manual , a class like this: abstract class Example {}
According to http://www.codeguru.com/forum/showthread.php?t=463663 , C#'s getHashCode function in 3.5 is implemented as: public override
I've got a PHP-fpm setup on nginx setup according to this article: http://interfacelab.com/nginx-php-fpm-apc-awesome/ PHP

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.