You can find IP address is using the $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables.
Or You can also try:
From CLI
PHP < 5.3.0
$myIp= getHostByName(php_uname('n'));
echo $myIp;
PHP >= 5.3.0
$myIp = getHostByName(getHostName());
echo $myIp;
For Client IP Address you can follow the below link:
Source: Get the client IP address using PHP