simple PHP code to display browser information

The below script will display three parameters namely

  • Browser:
  • Screen Resolution:
  • Browser resolution:

on your screen. Create a file binfo.php and place the file in your HTTP server with PHP enabled. Open the file to know about your browser, screen and browser resolution. The below example is written in three languages javascript, PHP, html which are very extensively used by web developers.

<html xmlns="">
<title>Browser Information</title>
<script language="Javascript">
document.write("<form method='POST' action ='<? echo $PHP_SELF; ?>'>");
document.write("<input type='hidden' name='version' value='" + navigator.appVersion + "'>");
document.write("<input type='hidden' name='type' value='" + navigator.appName + "'>");
document.write("<input type='hidden' name='screenWidth' value='" + screen.width + "'>");
document.write("<input type='text' style='display:none' name='screenHeight' value='" + screen.height + "'>");
document.write("<input type='hidden' name='browserHeight' value='" + document.body.offsetHeight + "'>");
document.write("<input type='hidden' name='browserWidth' value='" + document.body.offsetWidth + "'>");
document.write("<input type='submit' value='Get browser information'><p>");
echo "<b>Browser:</b> $type Version: $version<br>";
echo "<b>Screen Resolution:</b> $screenWidth x $screenHeight pixels.<br>";
if ($browserWidth != 0) :
echo "<b>Browser resolution:</b> $browserWidth x $browserHeight pixels.";
else :
echo "No JavaScript browser resolution support for this browser!";


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s