Here is my code:
if (getenv(HTTP_X_FORWARDED_FOR))
{
$pipaddress = getenv(HTTP_X_FORWARDED_FOR);
$ipaddress = getenv(REMOTE_ADDR);
}
else
{
$ipaddress = getenv(REMOTE_ADDR);
}
I am getting this error:
use of undefined constant http_x_forwarded_for-assumed http_x_forwarded_for
i am not getting whats the actual problem. Help me out
You’re passing constants to
getenv(), which actually requires a string.Change to:
The reason it works with the constants is because PHP fails to find the constant, it then issues the warnings you’re seeing, and then falls back using the constant names as a string.
From the Manual: