Jump to content
php.lv forumi

Case


drellout

Recommended Posts

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 ?

Link to comment
Share on other sites

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.. ?

Link to comment
Share on other sites

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);
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...