Related to Return Statement in PHP

Hi, I’m a beginner

Let’s take an example:

function countdown() 
      echo "4, 3, 2, 1, ";
      return "blastoff!";
    $return_value = countdown();
    echo $return_value;

When the countdown() function is invoked it will print 4, 3, 2, 1

Also echo $return_value; will give blastoff!

But how?

I mean if $return_value = countdown(); So, echo $return_value should give value of countdown() that is 4, 3, 2, 1

Please help me to resolve this confusion!!


$return_value = countdown();

you capture the returned result.

echo only prints something to the screen. return is responsible for handing data back to the caller.