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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:40:05+00:00 2026-05-30T15:40:05+00:00

Here’s my code: <?php class Test_Class { public function Show() { return Test_Class->Show() function;

  • 0

Here’s my code:

<?php
    class Test_Class {
        public function Show() {
            return "Test_Class->Show() function";
        }
    }

    class Test_Class2 {
        public function Show() {
            echo "Test_Class2->Show() function";
        }
    }

    $var1 = new Test_Class();
    $var2 = new Test_Class2();

    echo "var1 :: " . $var1->Show() . "<br />";
    echo "var2 :: " . $var2->Show() . "<br />";
?>

Here’s the output:

 var1 :: Test_Class->Show() function  
 Test_Class2->Show() functionvar2 :: 

You’ll notice that the class that returns the string has the result appear where it normally would, whereas the class that echo’s the string has the result appear before the echo statement that it is called in.

Now, I know that it’s getting processed first, and that’s why it’s appearing first. But how does this look at a lower level?

It is something along the lines of:
.. parse
.. parse
…. Hey! And echo statement, let’s parse it!
…… Hey! inside this echo statement that we’re parsing is an object’s method, let’s parse that now
…….. Inside this method there’s an echo, so let’s evaluate it
(output’s inner echo statement)
….We finished evaluating the echo statement (output outer echo statement)
.. parse
.. parse

Is that close?

Anyone know the “order of operations” when it comes to this?

  • 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-30T15:40:06+00:00Added an answer on May 30, 2026 at 3:40 pm

    It’s nothing to do with parsing.

    echo needs an argument; it cannot be invoked until that argument is known. In your second example, that argument is formed from two concatenation operations. These operations must be performed before the argument is known. Therefore, the arguments to these concatenation operations must be evaluated first. So $var2->Show() is evaluated before any concatenation is performed.

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

Sidebar

Related Questions

here is javascript code: var test = { h : function (a) {return a;},
Here is my javascript code for a cursor focus function to go to username
Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>
Here is some code I made :) @echo off set source=R:\Contracts\ set destination=R:\Contracts\Sites\ ROBOCOPY
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here is the code: http://jsfiddle.net/GKBfL/ I am trying to get collection.prototype.add to return a
Here is my code, which takes two version identifiers in the form 1, 5,
Here is the code I'm using http://jsbin.com/evike5/edit When the jQuery UI dialog is fired
Here's some of my production code (I had to force line breaks): task =
Here's my problem I have this javascript if (exchRate != ) { function roundthecon()

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.