获取特定设备信息

Using just PHP, is there anyway to detect if the page is being loaded from a SPECIFIC device? Say, I would want the page to react differently if only MY iPhone was loading the page, no one else's?

The only solution I have so far is to use $_SERVER['REMOTE_PORT' in conjunction with $_SERVER['HTTP_USER_AGENT'], to verify iPhone, but that doesn't ensure a specific iPhone..

There is a really simple solution to use Mobile-detect here: https://github.com/serbanghita/Mobile-Detect/

Enjoy!

Only if that device sends such information.

You could use a cookie - have a setup page that requires you to log in, then send the cookie to the device. From then onward your device will send the cookie to other pages without needing to log in again.

By default devices do not send serial numbers or any other means of specifically identifying a device, probably because this would break some privacy rules.

$_SERVER['HTTP_USER_AGENT'] contains information about the browser and the device used. So if you know the User Agent - sent by your device - then you can quite easily write an if statement, that will see if it's the one you want or not.

However, usually you don't really want to play with manual aiming at the devices, especially when it comes down to mobiles. Think about using something like wurfl, a class that allows you to determine a type of device that loaded your webpage.

If you want to aim at specific iPhone you'd most likely want to compare it's user agent with user agent of another model. But as far as I know - it's very flawed method, and doesn't really work in a long term. So long answer short: There's no way to aim at very one specific iPhone model (because any of them sends roughly identical data to the server if they all got same iOS and same browser).

By using Mobile_Detect PHP class you can detect your mobile devices. It uses the user-agent string combined with specific HTTP headers to detect the mobile environment.