What are some best practices for running PHP scripts through the command line to avoid potential issues or errors?

When running PHP scripts through the command line, it is important to ensure that the correct version of PHP is being used and that any required dependencies are installed. Additionally, it is crucial to handle any potential errors or exceptions that may arise during script execution to prevent unexpected behavior or crashes.

try {
    // Your PHP script code here
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
    exit(1);
}