Skip to content

Instantly share code, notes, and snippets.

@UVLabs
Last active January 23, 2025 20:04
Show Gist options
  • Save UVLabs/b39fa648e51bf3d71162 to your computer and use it in GitHub Desktop.
Save UVLabs/b39fa648e51bf3d71162 to your computer and use it in GitHub Desktop.
Media Queries in PHP
<?php
if (isset($_GET['width'])) {
$width = $_GET['width'];
if ($width <= 480) {include ('mobile_file.php');} //mobile devices
} else {
echo "<script language='javascript'>\n";
echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}" . "&width=\" + screen.width; \n";
echo "</script>\n";
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment