so i wanna be able to have a condition like this.... if device == Test then include Test-home.php if device == test2 then include test2-home.php Thats an example. i want a way to load a page inside a URL so i can have different versions of the page loading on the same url. but i dont wanna have to worry about escaping 800 lines. how can i pull it off?
If I understood you correctly, you can do it like this: <?php for($i=1; $i<10; $i++){ if($device == "test".$i){ include "test".$i."-home.php"; } } ?> PHP:
oooo thats interesting. im talking more on the lines of a device i put test 1 ....2 in for the example. its gonna be more like if device == iphone then include iphone-home.php but i dont want to have to escape out the entire iphone-home.php page. because im going to have an entire pages content.. and im gonna have an iphone- version of my entire site. and a blackberry- but like i want to keep all the same pages visually thats why i want to use this system. internally this is whats gonna happen but user end they go to home.php and if they are on a particular device then that device-home.php is loaded but it still shows home.php as the url. same with any page on the site. and i dont want to have to escape out EVERY PAGE, because i have a full socal networking site im recoding into this. options to that?
You just do something like this: <?php if ( $thisDevice == 'something1' ) { // include something }elseif ( $thisDevice == 'something2' ) { // include something else }elseif ( $thisDevice == 'something3' ) { // include something else } ?> PHP: ..and so on... that's just my way, there's probable an easier solution.
switch ($device) { case "device #1": include("home-1.php"); break; case "device #2": include("home-2.php"); break; default: include("home-unknown.php"); } PHP:
As the above post shows but does not explain much, a switch will be alot better at getting the results you need. Have a look at this link for more information, http://php.net/manual/en/control-structures.switch.php Glen
What do you mean by escaping? if you want to include a page whose name is based on a string variable you can do it this way: <?php $st = "-home.php"; $devicename = $yourvar; $st = $yourvar."-home.php"; include $st; } ?> PHP:
sorry for the late reply. Yeah i did it similar to that @thewiseguy i did somethign like this $pageid = index.php <--- on the physical page... then i used a system which groups user agents so if a useragent has the term iphone in it, then device == iphone so then i created copies of every page and set a system to redirect if mobile == 1 and it redirects to $device - .$pageid. so iphone-index.php etc etc. thats a general idea of how i pulled it off. Thanks for your help though? any of you have skype?