What are the main differences between a CLI and a normal PHP installation?

The main differences between a CLI (Command Line Interface) and a normal PHP installation are the way they are executed and the environment in which they run. CLI scripts are run from the command line, while normal PHP scripts are accessed through a web server. CLI scripts do not have access to web server-specific variables like $_SERVER or $_POST. To address this issue, you can use the PHP function php_sapi_name() to determine if the script is running in a CLI environment. This allows you to adjust your script's behavior accordingly.

if (php_sapi_name() === 'cli') {
    // Code specific to CLI environment
} else {
    // Code specific to web server environment
}