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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:43:24+00:00 2026-05-11T19:43:24+00:00

I was explaining to a Java developer why his method call wasn’t working. He

  • 0

I was explaining to a Java developer why his method call wasn’t working. He just needed to add $this->method_name();

He then asked me, “Why do I need to add $this to the method when it’s declared in the same class?”

I didn’t really know how to answer. Maybe it’s because PHP has a global namespace and it you need to explicitly tell it that the method you are looking for belongs to the current class? But then why doesn’t PHP check the current class for the method BEFORE looking at the global namespace?

  • 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-11T19:43:24+00:00Added an answer on May 11, 2026 at 7:43 pm

    The problem would also be that if you declared a function foo() and a method foo(), php would have a hard time figuring out which you meant – consider this example:

    <?php
    function foo()
    {
        echo 'blah';
    }
    
    class bar
    {
        function foo()
        {
             echo 'bleh';
        }
        function bar()
        {
             // Here, foo() would be ambigious if $this-> wasn't needed.
        }
    }
    ?>
    

    So basically you can say that PHP – because of its “non-100%-object-orientedness” (meaning that you can also have functions outside classes) – has this “feature” 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 158k
  • Answers 158k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use a RequestDispatcher.include() method and buffered response. The… May 12, 2026 at 11:11 am
  • Editorial Team
    Editorial Team added an answer with php you can check for and only display results… May 12, 2026 at 11:11 am
  • Editorial Team
    Editorial Team added an answer Those are caused most likely by 2 issues: You need… May 12, 2026 at 11:11 am

Related Questions

I was explaining to a Java developer why his method call wasn't working. He
Trying to build a GUI application in Java/Swing. I'm mainly used to painting GUIs
I understand that the Windows API uses classes, relying to the WNDCLASS / WNDCLASSEX
I got into a mini-argument with my boss recently regarding project failure. After three
Like most developers, I'm a business developer, which in essence consists of slapping a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.