Tag Archives: safari

PHP: detecting mobile device

HTTP_USER_AGENT

Beside that most of the responses of $_SERVER[‘HTTP_USER_AGENT’] may return, it appears that this is the most reliable way to track down a user agent with PHP. It is weird that most of the clients, i.e. Safari and Chrome will return something with Mozilla in it’s strings, but however it’s enough to track the “chrome” or “safari” sub strings.

All the examples bellow are from Mac OS X:

Firefox 3.6:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6

Note: there are both Mozilla and Firefox sub strings!

Safari 4:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; bg-bg) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10

Chrome:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.11 Safari/532.9

Note: Here they are Mozilla, Chorme and Safari!!!

Opera:

Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.10

The day of mobile

Nowadays it’s normal to make a site with the presumption it will be visible from mobile. The war between Nexus One from Google and iPhone from Apple is just beginning and with all those devices with wide screens everything’s becoming more complicated.

User agent strings from Nexus One and iPhone

Both are weird, but both contain the keyword – “mobile” and that may help you make a check with something like this PHP snippet:

<?php
$mobile = !!(FALSE !== strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile'));
?>

YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!

What better example than that coming both from YouTube and Vimeo. Although video tag is not supported except under Safari and Chrome, that’s the future everyone’s going to embed sooner or later.

And if these “big players” are going that way, don’t hesitate to follow them! HTML5 is really what we as web developers were waiting for so long and even all of the problems during its standardization process it’s really cool there will be tags like video.

What YouTube is doing today, perhaps will seem normal to everyone tomorrow. However there are some questions still with no answer, as where the flash possibility to add ads into the player is going?! But we’re about to see great things from these two sites!

Just check out these two links:

Youtube HTML5

Vimeo

What should I optimize first in my web page?

I start with the optimization process …

It’s a common question! Where do I begin with the optimization process. Should I start with JavaScript or with some simple Apache optimizations? The answer is pretty simple and it’s related to a very, very simple technique.

Look what Firebug is saying

Yeah, look at the Firebug. You can check what’s taking most of the time to load. If it’s some server site script you can try caching it, if it’s a JavaScript file load, than you can try minify/compile it. Another good tool is the Safari developer tool. Than you can graphically understand what part of the sites’ components are slowing down the loading process. Whether the images or the JavaScript, well check that out with the Safari browser.

Finally what I do?

Once you know what’s the thing slowing down the site, start with its optimization! It’s really simple.