sam
sam

Reputation: 13

loading css for iPad useragent in PHP

I know it is possible to use media queries and JavaScript to load CSS classes if you want to target iPad's and iPhone's but is it possible to use PHP and if the user agent is iPad load "iPad.css" or iPhone load "iPhone.css" and remove the default "style.css"?

Upvotes: 0

Views: 1027

Answers (2)

user1721135
user1721135

Reputation: 7092

You could do it like this in php:

<?php
$isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');

if ($isiPad == true) { 
?>
<link rel="stylesheet" href="ipad.css">
<?php
} else {
?>
<link rel="stylesheet" href="nonipad.css">
<?php } ?>

Upvotes: 1

Roman  Kliuchko
Roman Kliuchko

Reputation: 499

May be you should check client browser with

$_SERVER['HTTP_USER_AGENT']

Upvotes: 1

Related Questions