PHP Classes


Recommend this page to a friend!
  Classes of Pierre-Henry Soria   PHP Mobile Phone Detection   Download  
Role: Documentation
Content type: text/markdown
Description: Read me
Class: PHP Mobile Phone Detection
Detect when a site use is using a mobile phone
Author: By
Last change: README: Update description
Update PHP version required

PHP 7.3 => 7.2
README: Improve code example
README: Fix typo in code example
README: Update library's description
Date: 3 years ago
Size: 2,084 bytes


Class file image Download

? PhoneDetector

Lightweight PHP 7.2 library that detects users' mobile phone based on the device OS.

? Installation (with Composer)

composer require ph-7/phonedetector

? Usage

Below are two simple examples of what you can do with PhoneDetector library.

Example 1

use PierreHenry\PhoneDetector\PhoneDetector;

$phoneDetector = new PhoneDetector();
if ($phoneDetector->isAndroid()) {
    echo 'Your mobile phone is Android!';

if ($phoneDetector->isIos()) {
    echo 'Your mobile phone runs with iOS';

Example 2

require 'vendor/autoload.php'; // Include Composer to load the library

use PierreHenry\PhoneDetector\PhoneDetector;

$phoneDetector = new PhoneDetector();

if ($phoneDetector->isAndroid()) {
    $url = '';
} elseif($phoneDetector->isIos()) {
    $url = '';
} else {
    $url = 'https://DEFAULT-URL.example';

header('Location: ' . $url);

? Author

Pierre-Henry Soria")


[Pierre-Henry Soria][author-url], a Passionate, Zen&Cool Belgian Software Engineer :belgium: :chocolate_bar:

? Used By...

I initially created PhoneDetector to redirect users to the correct app's store for depending on the mobile device.

? Server Requirement

PHP 7.2 or higher.

? License

PhoneDetector library is generously distributed under [MIT License][license-url].

<!-- GitHub's Markdown reference links --> [author-url]: [license-url]: [twitter-image]: [twitter-url]: