Détéction de téléphone mobile avec php

J’ai découvert un script assez simple à utiliser si vous souhaitez creer une partie de votre site compatible avec les téléphones mobiles.
Pour cela, une class: mobile_redirect.php

 

 

Télécharger le script ici: http://simonboudrias.com/upload/class.detect_device-v2.zip

et pour l’utilisation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

    require_once('mobile_redirect.php'); // including the mobile_redirect() fonction

   

    // we're calling the function here, passing an array as a parameter

    mobile_redirect(array(

                          "others"=>false, // old not so smart phone wont be redirected

                          "ipad"=>"http://ipad.MySite.com", // Ipad gonna be redirected to a special iPad version

                          "mobileredirect"=>"http://m.MySite.com" // here we enter the URL where all other mobile gonna go

                          )); // and as desktopredirect is false by default, they gonna stay on this page

?>

à vous de créer un sous domaine (ou directement dans un nouveau dossier) et de changer la variable mobileredirect

Plus d’information: http://simonboudrias.com/blog/detecter-un-mobile-par-son-ua-en-php-5-oop/

Laisser un commentaire