php

How to Get IP Address of Server in PHP

In this tutorial, we are going to see how to get the IP address of the server in PHP. Use the following code if you want to display the IP address of the server. Simply copy the code to a text file and save it as a .php file on the server.

For Linux with Apache, use the following code:

<?php
	echo $_SERVER['SERVER_ADDR'];
?>

For Windows 2008 R2 with IIS 7.5 Server, use:

<?php
	echo $_SERVER['LOCAL_ADDR'];
?>
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *