Jump to content

$_SERVER


Archadian

Recommended Posts

1) Why do you need a variable that holds "localhost". Can't you use it directly? Same question goes for 127.0.0.1.

 

 

2) From one of the comments I found in the manual:

To get the server address, you can use $_SERVER['SERVER_ADDR']. However, this only works when your PHP process is running on a webserver, not when running PHP as CLI. Here is a function which will also return the server address when running on linux (eth0 is hardcoded as the network interface, modify if necessary).

 

<?php

function getServerAddress() {
   if($_SERVER['SERVER_ADDR']) {
       return $_SERVER['SERVER_ADDR'];
   }
  
   $ifconfig = shell_exec('/sbin/ifconfig eth0');
   preg_match('/addr:([\d\.]+)/',$ifconfig,$match);
  
   return $match[1];
}

?>

 

 

 

Orio.

Link to comment
https://forums.phpfreaks.com/topic/41134-_server/#findComment-199308
Share on other sites

I'm running XP, IIS 5 and $_SERVER['SERVER_ADDR'] is available.

 

If you are calling the page via your IIS server it should be there.

 

If I use the IIS control panel then on the Directory Security tab there is a section titled "IP and Domain name restrictions" but it is greyed-out/locked on mine. Check yours. You may be able to affect it from there.

Link to comment
https://forums.phpfreaks.com/topic/41134-_server/#findComment-199409
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.