Tag: PHP Code Snippets


Hello World! in PHP

The following is a code snippet to create Hello World! in PHP. <?php echo ‘Hello World’;

Get User’s IP Address using PHP

Use the following PHP code snippet to display the user’s IP address: <?php if (!empty($_SERVER[‘HTTP_CLIENT_IP’])) { $ip=$_SERVER[‘HTTP_CLIENT_IP’]; } elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $ip=$_SERVER[‘HTTP_X_FORWARDED_FOR’]; } else { $ip=$_SERVER[‘REMOTE_ADDR’]; } echo…

Automatic Copyright Year Using PHP

In this code snippet, I will show you how to display the copyright year using PHP automatically.To display the current year for copyright notices use the following code…