My code is as follows. In my understanding from diverse websites and the php documentation, empty()
is a language construct that checks whether the key exists, just like isset()
(only that it also does a loose 'false'-comparison in case the Variable or Key exists...
37 $origin =
38 !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] :
39 !empty($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] :
40 !empty($_SERVER['ORIGIN']) ? $_SERVER['ORIGIN'] :
41 "Unknown Origin";
Error:
Undefined index: ORIGIN in somePHPFile.php:40
Update: I fixed it by wrapping the else-parts in parentheses. When i have discovered the exact problem (associativity or else...) i will update this answer again.
$origin =
(!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] :
((!empty($_SERVER['HTTP_ORIGIN'])) ? $_SERVER['HTTP_ORIGIN'] :
(!empty($_SERVER['ORIGIN']) ? $_SERVER['ORIGIN'] :
"Unbekannte Herkunft"));