开发者

Starting Apache service with a variable that can be later accessed via PHP?

I 开发者_如何学Chave a need to start the Apache service with a parameter so that I can later access that parameter via PHP. Is this possible?


pass the parameter to httpd with the -C or -c (process the configuration directive before/after reading config files) command line option and the SetEnv directive:

httpd -C "SetEnv FOO bar"

FOO can now be accessed from PHP like so:

<?php
print getenv('FOO');

prints

bar


You can set an environment variable. See also: getenv


Based on the comments on your question, I'd say that using shared memory is an acceptable alternative. Take a look at shmop_open() et alia.


the httpd program will take a 'directive' when you start it up using -c, so experiment with that and SetEnv.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜