Is it possible to pass a $_SERVER variable to a PHP script via the command line?
Specifically I am trying to set the $_SERVER['recipient'] manually so I can test email piping without setting up a mail server.
Is it possible to pass a $_SERVER variable to a PHP script via the command line?
Specifically I am trying to set the $_SERVER['recipient'] manually so I can test email piping without setting up a mail server.
I personally use the following.
Example: set $_SERVER['recipient] in my PHP command line.
With OS X
Append the following line to the file '~/.bash_profile' (create it, if it does not exist)
export recipient="something@example.com"
With Ubuntu GNU/Linux
Append the following line to the file '/etc/environment' (create it, if it does not exist, see https://help.ubuntu.com/community/EnvironmentVariables)
recipient=something@example.com
How about setting up a dummy page called dummy.php with this contents:
The answer by @sberry is correct.
...but because I came to this page looking for setting default values for the
$_SERVER
array, when running PHP from command line, here is my own answer. Hope it might help somebody.On *nix:
Test:
Or, you can export it or setenv (depending on your OS), like