Hello,
I built PHP function that recognize if the user OS is mobile or regular computer. if its mobile the script will redirect the user to the site mobile version. the problem is that the site first got loaded and than after it finish it redirect the user to the mobile version.
How can I set it so my PHP function will load first?
Thank you in advance,
Roi.
page load
Moderator: General Moderators
Re: page load
Do you redirect by header() function?
The code bellow could work.
The code bellow could work.
Code: Select all
<?php
if(is_mobile($_SERVER)){
header('Location: mobile.site.com');
exit;
}else{
show_page();
}
?>
Last edited by dejvos on Mon Jul 19, 2010 8:31 am, edited 1 time in total.
Re: page load
Thanks dejvos,
Do I have to put the header code in the top of my page/code?
Imean- before I print anything to the screen...?
Do I have to put the header code in the top of my page/code?
Imean- before I print anything to the screen...?
Re: page load
Yes that's it,
you can manipulate with a header before you print anything else.
you can manipulate with a header before you print anything else.
Re: page load
OK, so I must put it in the top of my pages.
By the way, is there any chance that you know how to write the code above in ASP?
By the way, is there any chance that you know how to write the code above in ASP?
Re: page load
Unfortunately I don't know that. Try google.