I\'ve finally remembered what to ask. I never really got what : and ? do when a variable is being defined like this:
$ip = ($_SERVER[\'HTTP_X_FORWARDED_FOR\'
The ternary form is basically a shortcut for if->then->else
I generally avoid it because it's not all that readable.
$ip = ($_SERVER['HTTP_X_FORWARD_FOR']) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $_SERVER['REMOTE_ADDR'];
is logically equivalent to:
if($_SERVER['HTTP_X_FORWARD_FOR']){
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
It should be said that this is EXACTLY what this is most commonly used for: variable initialization. Very common with form data.