note 73330 added to reserved.variables

From: Date: Sun, 18 Feb 2007 14:43:07 +0000
Subject: note 73330 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-123538@lists.php.net to get a copy of this message
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]; } ?> ---- Server IP: 193.190.198.20 Probable Submitter: 84.192.183.108 ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.php Edit -- https://master.php.net/note/edit/73330 Del: integrated -- https://master.php.net/note/delete/73330/integrated Del: useless -- https://master.php.net/note/delete/73330/useless Del: bad code -- https://master.php.net/note/delete/73330/bad+code Del: spam -- https://master.php.net/note/delete/73330/spam Del: non-english -- https://master.php.net/note/delete/73330/non-english Del: in docs -- https://master.php.net/note/delete/73330/in+docs Del: other reasons-- https://master.php.net/note/delete/73330 Reject -- https://master.php.net/note/reject/73330 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123538) next »