What are some best practices for managing variable values in PHP scripts to prevent them from being overwritten?

When managing variable values in PHP scripts, it is essential to use proper scoping techniques to prevent variables from being overwritten unintentionally. One best practice is to use functions to encapsulate variables within their own scope, limiting their accessibility and reducing the chances of accidental overwriting.

function exampleFunction() {
    $variable = "value";
    
    // Use $variable within this function
}