Posted By

jaredyeo on 12/28/10


Tagged

javascript php redirect


Versions (?)

PHP redirect without javascript


 / Published in: PHP
 

URL: http://simplistika.com

  1. <?php
  2. require_once("mdetect.php");
  3. $uagent_obj = new uagent_info();
  4. $is_mobile = $uagent_obj->DetectSmartphone();
  5. if ($is_mobile)
  6. echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://m.google.com\">";
  7. else
  8. echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://google.com\">";
  9. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: confuxion on December 28, 2010

I'm sorry, color me newby in PHP, but I'm confused about the 2nd line in the above code:

require_once("mdetect.php");

What does the "mdetect.php" refer to? Or is it the way by which the above code should be named as a file? Again, sorry for what surely will seem like a stupid question. Thanks in advance for your reply.

Posted By: benastan on January 4, 2011

mdetect is a library that detects whether the user if is a smartphone. the functions require() and require_once() load php scripts/libraries.

why not simply use header() ?

requireonce("mdetect.php"); header("Location: " . ((uagentinfo::DetectSmartphone() )?"http://m.google.com":"http://www.google.com"));

You need to login to post a comment.