Jump to content

How do I print all environment variables (with names and values)?


Rasekamon

Recommended Posts

I've googled a lot but still can't find much of a clue for how to do this (printing all environment variables in PHP that is). :shrug:

I know it has something to do with $_ENV and $_SERVER but...

 

I would be thrilled for some guidance!

 

Best regards,

Rasekamon

*sigh*

$_ENV is an array. So you can process it like any other array.

Write some code and we can help, but I won't do it for you. If you can't get started, either this is too complex a task for you, or you're not stating the problem clearly.

Haha, thanks for your answers. Yeah it's homework.. and I just watched your little youtube link of "don't be this kid!!".. I'm totally that kid.

 

But ok, I'll freshen up on my array-skillz and try to do some loop that prints it all. Hope it's the right way to go :-)

Ah interesting. <pre> makes it look tidy and print_r() prints all the elements of the array. Neat!

 

Though it seems the array $_ENV is empty but the $_SERVER is full of stuff (I printed both):

 

"Array

(

)

Array

(

    [HTTP_HOST] => 127.0.0.1

    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13

    ... etc."

 

Thanks for your help. It's progress :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.