zero-perfoliate
zero-perfoliate

Author Topic: A Simple Branch please  (Read 214 times)

Offline KevInKauai

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
A Simple Branch please
« on: September 04, 2009, 02:59:50 PM »
I have an existing web site to which I want to add code that invokves a sub-directory (for browsing from a mobile device). Here is the top of the existing "index.php" file:
Code: [Select]
<?php

session_start
();

$title '';
$sidebar '';
$body '';
$header 'default';
I am attempting to modify this to detect a "mobile browser" (from various examples that I have found here and there on the 'net) but I am having a fundamental PHP logic problem (apparently). Here's what I modified the top of the "index.php" file to:
Code: [Select]
$mobile_browser = '0';
 
if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
    $mobile_browser++;
}
with mode that finally ends like this:
Code: [Select]
if($mobile_browser>0) {
   // do something
   header('Location: mobi/index.html');

}
else {
   // do something else

session_start();
ANy IDEAS? (Mahalo plenty ... KevInKauai)