drellout Posted July 4, 2010 Report Share Posted July 4, 2010 Vai butu labi taisīt lapu uz šāda koda ? <?php switch ($page) { case videos: include ("pages/videos.php"); break; case files: include ("pages/files.php"); break; case about_us: include ("pages/aboutus.php"); break; case contacts: include ("pages/contacts.php"); break; default: include ("pages/news.php"); } ?> Kādi -/+ ? Ir labāki varianti ? Quote Link to comment Share on other sites More sharing options...
drellout Posted July 4, 2010 Author Report Share Posted July 4, 2010 Pie reizes jautājums, ja sānāk šo variantu lietot kā var izdarīt ja tiek pieprasīta lapa kura nav sarakstā lai inklūdo 404.php ? Quote Link to comment Share on other sites More sharing options...
chizijs Posted July 4, 2010 Report Share Posted July 4, 2010 (edited) if(isset($_GET['page'])){ $fails = "./lapas/".$_GET['page']; if(file_exists($fails)){include($fails);}else{echo'error';} }else{ include('news.php'); } Edited July 4, 2010 by chizijs Quote Link to comment Share on other sites More sharing options...
drellout Posted July 4, 2010 Author Report Share Posted July 4, 2010 if(isset($_GET['page'])){ $fails = "./lapas/".$_GET['page']; if(file_exists($fails)){include($fails);}else{echo'error';} }else{ include('news.php'); } Sanāk ka ?do=videos.php tad būs vai arī jāreneimo fails videos.php uz videos Varbut ir kads variants kur varētu linku un inkludu failu/nosauk pats ielikt nevis ja ir.. ? Quote Link to comment Share on other sites More sharing options...
chizijs Posted July 4, 2010 Report Share Posted July 4, 2010 izdari šādi $fails = "./lapas/".$_GET['page'].".php"; un bus vienkarši ?do=videos Quote Link to comment Share on other sites More sharing options...
daGrevis Posted July 4, 2010 Report Share Posted July 4, 2010 Ko pēc tam var pārtaisīt par videos. Quote Link to comment Share on other sites More sharing options...
drellout Posted July 4, 2010 Author Report Share Posted July 4, 2010 izdari šādi $fails = "./lapas/".$_GET['page'].".php"; un bus vienkarši ?do=videos Paldies :) Quote Link to comment Share on other sites More sharing options...
codez Posted July 5, 2010 Report Share Posted July 5, 2010 Lasām par MVC. Quote Link to comment Share on other sites More sharing options...
indoom Posted July 5, 2010 Report Share Posted July 5, 2010 tik neaizmirsti to $_GET['page'] iztīrīt. Kaut vai ar $page = basename($_GET['page']); Quote Link to comment Share on other sites More sharing options...
Sappy Posted July 6, 2010 Report Share Posted July 6, 2010 Kurā brīdī es kaut ko daru nepareizi, ka man izvada tikai to kas atrodas blakus index.php (kods ir šajā failā), bet palūdzot parādīt ./add/ mapes saturu nav rezultāta? <?php $page = "./add/".$_GET['page']; if($page){ $site = file_exists($page.'.php') ? $page.'.php' : 'error.php';} else{ $site = 'home.php'; } include($site); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.