What if your code could tell you exactly what it just did, every time?
Why Return values in PHP? - Purpose & Use Cases
Imagine you are baking cookies and want to share the recipe results with your friend. You write down each step but never tell your friend what the final cookie tastes like or how many cookies you made. They have to guess or bake themselves to find out.
Without return values, your program can only do tasks but can't tell you what happened or give you results. This means you must repeat work or guess outcomes, which is slow and causes mistakes.
Return values let functions send back results after doing their job. It's like your recipe telling your friend exactly how many cookies were baked and how they taste, so they don't have to guess or redo the work.
$result = add(2, 3); echo "Sum is unknown";
$result = add(2, 3); echo "Sum is $result";
Return values let your code share results, making programs smarter and easier to build step-by-step.
When you order food online, the system returns your order number and estimated delivery time. Without this return info, you'd never know if your order went through or when to expect it.
Return values let functions send back results.
This avoids repeating work and guessing outcomes.
They help build clear, step-by-step programs.