How can unformatted PHP code affect the functionality of a script?

Unformatted PHP code can make it difficult to read and understand, which can lead to errors and bugs in the script. To solve this issue, it is important to properly format the code by using consistent indentation, spacing, and commenting.

// Example of properly formatted PHP code
<?php

    $variable = "Hello, World!";
    echo $variable;

?>