What is the best practice for returning values from a PHP file to be used in another file?

When returning values from a PHP file to be used in another file, the best practice is to use functions to encapsulate the logic and return the desired value. This way, you can include the PHP file in the file where you need the value and call the function to retrieve it. This approach helps keep your code organized and makes it easier to reuse the logic in different parts of your application.

// values.php
function getValue() {
    return "This is the value to be returned";
}

// index.php
include 'values.php';
$value = getValue();
echo $value;