How can the use of echo within functions be considered bad practice in PHP?

Using echo within functions can be considered bad practice in PHP because it mixes business logic with presentation logic, making the code harder to maintain and test. Instead, it's better to separate the logic and presentation by returning values from functions and then echoing them where needed in the script.

// Bad practice - mixing logic and presentation
function greetUser($name) {
    echo "Hello, " . $name;
}

// Good practice - separating logic and presentation
function greetUser($name) {
    return "Hello, " . $name;
}

echo greetUser("John");