Commonly Use PHP Server Variables

Last modified: 
Tuesday, May 5th, 2015
Topics: 
PHP

Here are some commonly used $_SERVER array variables I routinely forget.

Get a Remote User's IP Address

<?php
  $_SERVER['REMOTE_ADDR'];
?>

Get the Port a Request is Coming in On

<?php
  $_SERVER['SERVER_PORT'];
?>

References

PHP Manual Page for $_SERVER Variables


The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.