mercredi 11 avril 2018

Redirect to URL - PHP

I have this function where it checks which divice you are on. What I want now it that it will redirect to a page if the if statement is true I know how to return a message but I don't know how to redirect instant when if statement is true. for example if($android){ it needs to redirect to google.com

I want it to redirect to https://itunes.apple.com/us/app/bezorgland/id1364919752?mt=8 but that isnt working I get an error then

function user_agent(){
        $iPod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
        $iPhone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
        $iPad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
        $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");

        if($iPad||$iPhone||$iPod){
            return 'ios';
        }else if($android){
            return 'android';
        }else{
            return 'pc';
        }
    }

1 commentaire: