Posted By

jaredyeo on 12/28/10


javascript php redirect

Versions (?)

PHP redirect without javascript

 / Published in: PHP


  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=\">";
  7. else
  8. echo "<meta http-equiv=\"refresh\" content=\"0;URL=\">";
  9. ?>

Report this snippet  


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:


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() )?"":""));

You need to login to post a comment.