Met welke code laat je eigenlijk herkennen of iemand op een Android/Apple zit en dat dan iets weergeeft?
Bedankt
Bedankt
?[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]
?> Thommity schreef:NeeJij bent ook niet echt slim hè met php..
. Kan iemand me aub ff helpen?Thommity schreef: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 iPhoneJe ziet toch dat het een functie is?
Thommity schreef:Klein beetje, iets waardoor je uit niet meerdere keren moet typen ofz?Weet je wat een "functie" is?
Sanderc schreef:Je had het ook gewoon kunnen googelen.Klein beetje, iets waardoor je uit niet meerdere keren moet typen ofz?Eerdere citaten tonen
Thommity schreef:Weet je wat een "functie" is?
Jponsen schreef:En als hij false terug geeft dan?verander die echo in
echo Jij zit op een: .mobile_user_agent_switch();
if(mobile_user_agent_switch() != false) {
echo Jij zit op een: .mobile_user_agent_switch();
}