Jump to content

Is there a way on php to print or view all the environment variables and to determine if they are set or not.


Recommended Posts

Not asking you to troubleshoot for me but to pop in any thoughts you might have on how YOU would troubleshoot this problem.. Thanks

This is a wp site.. and generated the following error..
 

Notice: Undefined index: USER_AGENT in /home/luxuryrealtygrp/public_html/wp-content/plugins/LRG/Masked/Filters.php on line 31
This is what line 31 that is being called out:
Line 31:
function lrg_masked_field($false, $field_name){
    if(is_user_logged_in() || stripos($_SERVER['USER_AGENT'], 'google') !== false || stripos($_SERVER['USER_AGENT'], 'yahoo') !== false || stripos($_SERVER['USER_AGENT'], 'bing') !== false){
        return false;
    }

Just looking for ideas that might help to chase this down..
My guess is that USER_AGENT since in all caps may be an environment variable.. Is there a way to display all environment variablles and if they are set or not.  Any ideas or thoughts would be appreciated.. Thanks!

 

 

Edited by tommytx

Capital letters does not make it an environment variable. It it were then you would probably be using $_ENV instead of $_SERVER.

https://www.php.net/manual/en/reserved.variables.server.php
HTTP headers stored in $_SERVER are prefixed by "HTTP_". Take a look on that page to see if maybe there's something useful.

To the question itself (since it is possible the User-Agent header may not be passed) then then solution is to check if the value is set before trying to use it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.