What are the differences in executing a PHP script from the console compared to running it through a web browser?

When executing a PHP script from the console, you do not have access to superglobals like $_GET, $_POST, or $_COOKIE. This means you will need to pass any necessary parameters as command line arguments or read input from the user. Additionally, output from the script will be displayed directly in the console rather than in a browser window.

<?php
// Example of passing parameters to a PHP script from the console
if ($argc < 2) {
    echo "Usage: php script.php <name>\n";
    exit;
}

$name = $argv[1];
echo "Hello, $name!\n";
?>