Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Excerpt

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:

Code Block
<?php

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

?>