Passing an environment-variable into a php commandline script -
i want set environment-variable, access in php, cannot find how so.
in (linux) shell, run:
$ app_env="development" $ export $app_env
then run simple test script testenv.php:
<?php print $_env["app_env"]; print getenv("app_env");
from same shell variable set:
$ php testenv.php
this prints nothing , throws notice:
notice: undefined index: app_env in /xxxx/envtest.php on line 2
notice makes sense, because app_env not found in environment-variables, getenv()
throws no warning returns nothing.
what missing?
don't use $
in export
command, should be:
export app_env
you can combine assignment:
export app_env="development"
with $
, doing:
export development
Comments
Post a Comment