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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:15:53+00:00 2026-06-09T04:15:53+00:00

Possible Duplicate: where we use object operator “->” in php In PHP 5, what

  • 0

Possible Duplicate:
where we use object operator “->” in php

In PHP 5, what are the advantages of typing $class::method() instead of $class->method()?

As in any performance or functional differences. Or is this just a way of forcing code non-PHP4 friendly because of the complete rewrite?

  • 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-09T04:15:54+00:00Added an answer on June 9, 2026 at 4:15 am

    In PHP5, the two aren’t interchangeable.

    Static method calls will perform faster than non-static calls (over many iterations) but then the method is called in the static context and there is no object available to the called method.

    The only reason PHP lets you call a non-static method using the static notation was for backwards compatibility in PHP 4 (because PHP 4 didn’t have the static modifier for functions, or public/protected/private). If you do call a non-static method statically, you get a warning about “Strict Standards” output, and eventually this may fail with a fatal error.

    So the answer really is to call the method the way it was supposed to be called. If it is a static method in PHP 5, then call it statically Class::method(), if it is a public method, then call it using the object $class->method().

    Consider this code (run in PHP 5):

    class Foo {
        protected $bar = 'bar';
    
        function f() {
            echo $this->bar;
        }
    }
    
    echo Foo::f(); // Fatal error: Using $this when not in object context
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is it OK to use “delete this” to delete the current object?
Possible Duplicate: Difference between “var” and “object” in C# I would like to know
Possible Duplicate: PHP class instantiation. To use or not to use the parenthesis? Omission
Possible Duplicate: Why does var evaluate to System.Object in “foreach (var row in table.Rows)”?
Possible Duplicate: PHP class instantiation. To use or not to use the parenthesis? I'm
Possible Duplicate: What is it called when you use object… as a parameter? I'm
Possible Duplicate: Why use getters and setters? Is there any advantage to making methods
Possible Duplicate: Can we use any other TAG inside <ul> along with <li>? Or
Possible Duplicate: How to use include within a function? i have two file inc.php
Possible Duplicates: What does this expression mean “!!” What does the !! operator (double

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.