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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:10:03+00:00 2026-05-23T01:10:03+00:00

http://codepad.viper-7.com/ezvlkQ So, I’m trying to figure out: …?php $object = new A(); class A

  • 0

http://codepad.viper-7.com/ezvlkQ

So, I’m trying to figure out:


...?php

$object = new A();

class A 
{
  static public $foo = 'bar';
  function displayFoo()
  {
    echo $this->$foo;
  }
}

A::displayFoo();
A->displayFoo();
?>

About this, how many errors can you find? Can you tell me what they are in real human terms? I can’t really interpret what is and what is not okay from the validator that codepad uses…

  • 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-23T01:10:04+00:00Added an answer on May 23, 2026 at 1:10 am

    I’ve updated your code here http://codepad.viper-7.com/UaUE4g

    Error 1:

    echo $this->$foo;
    

    This should read:

    echo self::$foo;
    

    .. as it is static.

    Error 2:

    A::displayFoo();
    

    The method is an instance method :: is used for access to static methods.

    Error 3:

    A->displayFoo();
    

    This is an error because A is undefined and if it was it should have read $A. This would be okay:

    $object->displayFoo();
    

    .. as $object is an instance of class A.

    Next step, consult the manual on the topic static.

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

Sidebar

Related Questions

Please see the link for the sample php code being printed: http://codepad.viper-7.com/3ITmRL
http://codepad.viper-7.com/I0Zqoi I don't understand what's wrong with this or how to fix it or
Here's the generic workaround I am using: http://codepad.viper-7.com/2tiPvN $j=0; $paper = array('copier' => Copier
Why are the two regular expressions evaluating the email differently in this example? http://codepad.viper-7.com/SEgMzZ
I used to use: http://codepad.viper-7.com However it seems like it's down atm. Are there
http://mysite.com/songs/company-name/song-name i want to redirect it to http://mysite.com/songs/index.php?name=company-name&song=song-name i read some articles about that
Feel free to run the codes here: http://codepad.org/SAOaOABn Code: <?php $time = time(); echo
I used this tutorial http://delphi.about.com/od/kbthread/a/thread-gui.htm to create a class that asynchronously downloads a file
I have a PHP CLI script ( http://codepad.org/w6iyLLdv ) which stubbornly returns exit code
I wrote a sample program at http://codepad.org/ko8vVCDF that uses a template function. How do

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.