Apple/Android herkennen

Gestart doorSanderc21 reacties7 weergaven

22 berichten · pagina 1 van 2

Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Met welke code laat je eigenlijk herkennen of iemand op een Android/Apple zit en dat dan iets weergeeft?

Bedankt
0
Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja, maar ik bedoel dus als je op Apple zit dat er dan staat:

Ik zit op Apple

Op android

Ik zit op Android

Want veel mensen snappen deze shit niet dat die nu weergeeft. et zijn er trouwens meer...
0
Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja confused?

Ik heb er een echo aan toegevoegd zodat hij dat weergeeft maar dan wekrt het nog steeds niet?

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
*    Mobile device detection
*/[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]( ![/COLOR][URL="http://www.php.net/function_exists"]function_exists[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]mobile_user_agent_switch[/COLOR][COLOR= #007700]) ){
    function[/COLOR] mobile_user_agent_switch[COLOR= #007700](){[/COLOR]
        [COLOR= #0000BB]$device[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
 
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/stristr"]stristr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_USER_AGENT[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]ipad[/COLOR][COLOR= #007700]) ) {[/COLOR]
            [COLOR= #0000BB]$device[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"ipad"[/COLOR][COLOR= #007700];
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/stristr"]stristr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_USER_AGENT[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]iphone[/COLOR][COLOR= #007700]) ||[/COLOR] [URL="http://www.php.net/strstr"]strstr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_USER_AGENT[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]iphone[/COLOR][COLOR= #007700]) ) {[/COLOR]
            [COLOR= #0000BB]$device[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"iphone"[/COLOR][COLOR= #007700];
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/stristr"]stristr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_USER_AGENT[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]blackberry[/COLOR][COLOR= #007700]) ) {[/COLOR]
            [COLOR= #0000BB]$device[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"blackberry"[/COLOR][COLOR= #007700];
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/stristr"]stristr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_USER_AGENT[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]android[/COLOR][COLOR= #007700]) ) {[/COLOR]
            [COLOR= #0000BB]$device[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"android"[/COLOR][COLOR= #007700];
        }[/COLOR]
 
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$device[/COLOR] [COLOR= #007700]) {[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$device[/COLOR][COLOR= #007700]; 
        }[/COLOR] [URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700]; {[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
        }
    }
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Jij zit op een "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$device[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
?>
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jij bent ook niet echt slim hè met php..
0
Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thommity schreef:
Jij bent ook niet echt slim hè met php..
Nee confused. Kan iemand me aub ff helpen?
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je ziet toch dat het een functie is?
0
Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thommity schreef:
Je ziet toch dat het een functie is?
Ja? Maar ik wil dat het iets weergeeft als je op een Apple zit, dus als ik dan de site bezoek dan zie ik ergens staan: Jij bezoekt deze sit met iPhone
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Weet je wat een "functie" is?
0
Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thommity schreef:
Weet je wat een "functie" is?
Klein beetje, iets waardoor je uit niet meerdere keren moet typen ofz?
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
verander die echo in
echo Jij zit op een: .mobile_user_agent_switch();
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sanderc schreef:
Eerdere citaten tonen
Thommity schreef:
Weet je wat een "functie" is?
Klein beetje, iets waardoor je uit niet meerdere keren moet typen ofz?
Je had het ook gewoon kunnen googelen.
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jponsen schreef:
verander die echo in
echo Jij zit op een: .mobile_user_agent_switch();
En als hij false terug geeft dan?

if(mobile_user_agent_switch() != false) {
        echo Jij zit op een: .mobile_user_agent_switch();
}
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren