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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:14:48+00:00 2026-05-30T07:14:48+00:00

Yes, I have googled this question and even referred to my textbook (PHP by

  • 0

Yes, I have googled this question and even referred to my textbook (PHP by Don Gosselin) but I seriously can’t seem to understand the explanation.

From my understanding:

echo = shows the final result of a function

return = returns the value from a function

I applied both echo and return in the following functions I can’t see the difference or the ‘effectiveness’ of using return instead of echo.

<?php
echo "<h1 style='font-family:Helvetica; color:red'>Using <em>echo</em></h1>";
function add1($x, $y){
    $total = $x + $y;
    echo $total;
}
echo "<p>2 + 2 = ", add1(2, 2), "</p>";

echo "<h1 style='font-family:Helvetica; color:red'>Using <em>return</em></h1>";
function add2($x, $y){
    $total = $x + $y;
    return $total;
}
echo "<p>2 + 2 = ", add2(2, 2), "</p>";

?>

Both display the result!
What am I not understanding?

  • 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-30T07:14:50+00:00Added an answer on May 30, 2026 at 7:14 am

    I’m going to give a completely non-technical answer on this one.

    Let’s say that there is a girl named Sally Function. You want to know if she likes you or not. So since you’re in grade school you decide to pass Sally a note (call the function with parameters) asking her if she likes you or not. Now what you plan on doing is asking her this and then telling everyone what she tells you. Instead, you ask her and then she tells everyone. This is equivalent to returning (you getting the information and doing something with it) vs her echoing (telling everyone without you having any control).

    In your case what is happening is that when Sally echos she is taking the control from you and saying “I’m going to tell people this right now” instead of you being able to take her response and do what you wanted to do with it. The end result is, however, that you were telling people at the same time since you were echoing what she had already echoed but didn’t return (she cut you off in the middle of you telling your class if she liked you or not)

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

Sidebar

Related Questions

This seems like the dumbest question ever, but I can't seem to figure it
I've googled , asked, searched, done everything but I don't have enough info about
I know this is a trivial question. But I have search all over google
Firstly , This may look like a duplicate question but trust me I have
(Before I start, yes I have asked a similar question before; unfortunately due to
I have a very simple yes no question: should static methods have same result
I have completed the assignment (yes it is for a programming class), but I
I have the following code (Yes I know it's quite long winded, but I
Yes, I have searched and tried many techniques, but nothing seems to work. Here
I have asked this question here about a Python command that fetches a URL

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.