Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to identify server IP address in PHP?
The server IP can be identified with the below line of code −
$_SERVER['SERVER_ADDR'];
The port can be identified using the below line of code −
$_SERVER['SERVER_PORT'];
For PHP version 5.3 and higher, the following lines of code can be used −
$host_addr= gethostname(); $ip_addr = gethostbyname($host_addr);
This can be used when a stand-alone script is being run (which is not running via the web server).
Advertisements
