This topic is locked
[SOLVED]

Test environment variable

8/24/2025 2:17:08 AM
PHPRunner General questions
J
Jan author

Based on Sergey's video, I did the same test. I'm getting an error message. What am I doing wrong ?
img alt

img alt

img alt

img alt

Sergey Kornilov admin 8/24/2025

Did you make sure that $_ENV["mypassword"] actually holds the required value?

C
Corrie De Wet 8/25/2025

Your environment variable name is: "test" and the value is "mypassword".
The code should look like this: $pwd = $_ENV["test"]
I hope this helps.

J
Jan author 8/26/2025

Hi Corrie, the text above is a mistake. I've used the correct parameters:

img alt

But the error message remains ...

Sergey Kornilov admin 8/27/2025

@Jan,

did you see my question?

W
wpl 8/27/2025

Jan,

did you make sure that ENV is listed in the "variables_order" section of your php.ini?

; This directive determines which super global arrays are registered when PHP
; starts up. G,P,C,E & S are abbreviations for the following respective super
; globals: GET, POST, COOKIE, ENV and SERVER.
; Default Value: "EGPCS"

Otherwise

$_ENV

will be empty.

J
Jan author 8/28/2025

Sergey, the variable is visible in the console (CMD),

I replaced the line $pwd = $_ENV["test"]; with this line $pwd = getenv('test');

Now it works fine. Thanks.