PHP $_SERVER[‘SERVER_ADDR’] variable always returns 127.0.0.1
问题 We have multiple load-balanced webserver machines running the same PHP webapp (LAMP) and I'd like to run slightly different code on each server ( for testing purposes ). I was hoping to use the $_SERVER['SERVER_ADDR'] super global to do something like this: if ($_SERVER['SERVER_ADDR'] == 'XXX.XXX.XXX.XXX') { echo "Do one thing"; } elseif ($_SERVER['SERVER_ADDR'] == 'YYY.YYY.YYY.YYY') { echo "Do something else"; } Unfortunately, this doesn't work because both machines are setting $_SERVER[