Answers for "Detect Mobile Platform On Php"

PHP
0

Detect Mobile Platform On Php

<?php


function detect_platform() {
	if (preg_match('/iphone|ipad|ipod/i', $_SERVER['HTTP_USER_AGENT'])) {
		if (!preg_match('/safari/[0-9]+/i', $_SERVER['HTTP_USER_AGENT'])) {
			return 'ios-share';
		} else {
			return 'ios';
		}
	} else if (stripos($_SERVER['HTTP_USER_AGENT'], 'android')!==false) {
		return 'android';
	} else {
		return 'default';
	}
}
Posted by: Guest on February-10-2022

Browse Popular Code Answers by Language