To get started, write a simple
<?php echo phpinfo(); ?>
routine. This will display all of the available globals like
$REMOTE_ADDR (ip address) and
$HTTP_USER_AGENT (browser information)
Be aware that ip addresses may not be exactly what you expect. For example, users using a proxy server will all appear to have the same address.
You might also want to consider just using the logs already being generated by your web server.