PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Dec 12, 2017 9:15 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Jan 12, 2012 5:21 pm 
Offline
Forum Newbie

Joined: Wed Dec 28, 2011 5:46 pm
Posts: 4
On my web site I am attempting to :

1 - Write a function to identify the Window Phone Mobile device
2 - echo a link for that device if the device exists that sends the device to the windows phone app store: zune://navigate/?appID=**************************. I don't want to send users to a specific mobile site (I've seen lots of examples on how to do that), only provide them one tailored link if they have a Windows phone.
3 - Else echo a link tailored for a desktop browser. http://windowsphone.com/s?appId=******* ... **********

My HTML code only executes to the point where the function exists, so syntax may be an issue; however, does this approach work in principle?

Syntax: [ Download ] [ Hide ]
<?php
            function mobileDevice() {
                                $type = $_SERVER['HTTP_USER_AGENT'];
                                if(strpos((string)$type, "Windows Phone") != false)
                                        return true;
                                else
                                        return false;
                        }                      
                        ?>

                <?php
//Calling the function in a list.
                        if(mobileDevice() == true) {
                        echo '<dd id="d4"><a href="zune://navigate/?appID=*************************" title="Windows Phone Marketplace" target="_blank">Windows Phone Marketplace</a></dd>';
}
                        else
                        echo '<dd id="d4"><a href="http://windowsphone.com/s?appId=*********************************" title="Windows Phone Marketplace" target="_blank">Windows Phone Marketplace</a></dd>';
                ?>            
 


Thanks in advance for your suggestions and help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group