Can you provide examples or resources for further understanding how to handle PHP scripts based on their runtime environment?

When dealing with PHP scripts that need to behave differently based on their runtime environment (e.g., development, staging, production), one common approach is to use environment variables to determine the environment and adjust the script behavior accordingly. Here is an example of how you can use environment variables to handle different runtime environments in PHP:

```php
$env = getenv('ENVIRONMENT');

if ($env === 'development') {
    // Code specific to the development environment
} elseif ($env === 'production') {
    // Code specific to the production environment
} else {
    // Default behavior if environment variable is not set or invalid
}
```

In this code snippet, we are checking the value of the 'ENVIRONMENT' environment variable to determine the runtime environment. You can set this variable in your server configuration or in a .env file. Based on the value of the variable, you can execute different code blocks specific to each environment.