How to define env values that start with dollar sign in php-fpm


I need to define a variableSOMECONFIG in php-fpm with a string$hello (a literal string that starts with a dollar sign)

If I put it like


It won't work because php-fpm will try to evaluate$hello from the environment variables which is not defined. The result of$_SERVER['SOMECONFIG'] in php code will be an empty string.

What's strange about php-fpm is if the dollar sign is NOT at the beginning of the string, it can be defined without issues, the following works:


I've also tried with\$hello,$$hello,'$hello', or"$hello" without luck.





I found a workaround. Set the base64 encoded of "$hello" to an environment variable and decode it when use it.

in parameters.yml in Symfony3.4, I was able to get the value like this: %env(base64:SOMECONFIG)%

People are also looking for solutions to the problem: php - Can not join in a doctrine query


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.