You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The easiest way to get local IP Address in PHP on CentOS is using shell command like "hostname -I". I tried several methods to get it, but most of them returns the wrong answer.

Followings are the example:

<?php

	$ip = shell_exec("hostname -I");
	echo "local IP address={$ip}\n";

?>


  • No labels