<p>I have a PHP script that needs to determine if it's been executed via the command-line or via HTTP, primarily for output-formatting purposes. What's the canonical way of doing this? I had thought it was to inspect <code>SERVER['argc']</code>, but it turns out this is populated, even when using the 'Apache 2.0 Handler' server API.</p>

I think
```
```
$_SERVER['REMOTE_ADDR']
```
```
will not be populated from the CLI.
Also, all the HTTP_* keys in the $_SERVER superglobal won't be populated from the CLI, or do it the right way hop just mentioned :-)