Re: [ask]make dynamic mobile friendly website with php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The one thing you got to remember about php is that it has always been
closer to a template system than anything and will still hold that
functionality with version 4, 5, and beyond. Thus, all you have to do
is format your php files in a right manner with this in mine.

XHTML is the widest available standard, while WML is being pushed
aside as a unusful relic of the third generation Cellular phones, yes
Cellular not the current "Smart" phones(ie pda w/web+music player and
a cellular phone in one). See this wikimedia article,
http://en.wikipedia.org/wiki/File:Mobile_Web_Standards_Evolution_Vector.svg

Now to answer your questions, yes php can support both. Why well as I
stated earlier it can output what ever manner of markup language you
can conceive simply by having the needed data from the database
handler echoed out in the right places. An example of this would be;

[code: controller.php]
<?php
$res = $db->query("SELECT * FROM pages WHERE name='index';");
...
switch($_GET['format']) {
case "xml":  //xmlrpc API
  include "templates/view-xml.inc.php";
  break;
case "json": //JSON API
  include "templates/view-json.inc.php";
  break;
case "rss":  //rss aggragated feed
  include "templates/view-rss.inc.php";
  break;
case "wml":  //pre-2006 mobile phones
  include "templates/view-wml.inc.php";
  break;
default:     //By default use semanticly correct XHTML
  include "templates/view-html.inc.php";
  break;
?>

[code: view-wml.inc.php]
<card id="main" title="First Card"
 <?= $res['content']; ?>
</card>

[code: view-html.inc.php]
<html>
 <head><title>First Card</title></head>
 <body><a name="main"></a><?= $res['content']; ?></body>
</html>
[/code]

Now with that said, the best of practice these days is to use a sub
domain either m.example.com or mobile.example.com and have that load
in an alternate css and the same html with slightly larger font.

So, all in all it really comes down to is when people surf the web
they want the same web that they have on thier computer not two or
three just based on what device they have.

I hope this helps.

Cheers,
Dwight Spencer (Denzuko) <denzuko@xxxxxxxxxxxx>
http://denzuko.wordpress.com/


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux