A
A
Alexander Diunov2014-09-01 07:23:19
PHP
Alexander Diunov, 2014-09-01 07:23:19

How to pass value to php script from php server configuration?

You need to somehow register a value in the php configuration, which can then be obtained in a php script.
For example: server = 123
The nginx + php-fpm bundle is running on the server.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Senkevich, 2014-09-01
@adiunov

This can be done through the fastcgi_param directive:

...
location ... {
    ...
    fastcgi_pass ...;
    fastcgi_param MY_PARAM "123";
   ...
}
...

In the php script, access to the parameter value is obtained through $_SERVER['MY_PARAM'].

V
Vladimir, 2014-09-01
@rostel

ini-get

A
artjomtro, 2014-09-01
@artjomtro

Create a file variables.php, enter the variables there.
Example:

<?
$server = 123
?>

In the script where you need to get this value, add include
Example:
<?
// ....... твой код
include "variables.php"
// ....... твой код
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question