I had code on a new virtual machine that looked like this. It is called from a javascript file:
<?php $hostip = $_SERVER['REMOTE_ADDR']; ?> var myip = "<?=$hostip ?>";
Of course, I was working on an old server, and for a while I scratched my head, thinking that something was wrong with Apache. We donβt have a module there? Can I find some obscure Apache parameter ?. I thought Apache was not sending server variables. This was until I tried a simple way and it worked:
echo $_SERVER['REMOTE_ADDR'];
It turned out that I needed to edit php.ini and set short_open_tag to On . Facepalm - php shortcuts shortcuts did not work. Hope this helps save someone else head of time :)
source share