Get client system information in php

In PHP, you can retrieve certain system information from the client's machine using the $_SERVER superglobal variable and other PHP functions.

Here are some examples:

  1. User Agent
  2. IP Address
  3. Screen Resolution
  4. Timezone

User Agent

The user agent string contains information about the client's browser and operating system. You can retrieve it using the $_SERVER['HTTP_USER_AGENT'] variable.

$user_agent = $_SERVER['HTTP_USER_AGENT'];
echo "User Agent: $user_agent";

IP Address

You can retrieve the client's IP address using the $_SERVER['REMOTE_ADDR'] variable.

$ip_address = $_SERVER['REMOTE_ADDR'];
echo "IP Address: $ip_address";

Screen Resolution

You can retrieve the client's screen resolution using JavaScript and pass it to PHP using AJAX.

var width = screen.width;
var height = screen.height;

    type: "POST",
    url: "get_resolution.php",
    data: { width: width, height: height }

In the get_resolution.php file, you can retrieve the values using the $_POST variable. For example:

$width = $_POST['width'];
$height = $_POST['height'];
echo "Screen Resolution: $width x $height";


You can retrieve the client's timezone using the date_default_timezone_get() function.

$timezone = date_default_timezone_get();
echo "Timezone: $timezone";


Added  Mar 04, 01:17 pm

Article tags

SignUp with Email