douju1365 2010-12-08 15:50
浏览 37

如何使用开关为一个案例添加两个值?

im trying to create a website using switch commands to navigate with the contents displayed in a table via echo content. everything works fine. but one of the pages consists of multiple pages. The address looks like this website/index.php?content=home etc. but i want to make it like this for the page consisting multiple pages website/index.php?content=home&page=1

my index code:

<?php
switch($_GET['content'])
{
        case "home":
  $content = file_get_contents('home.php');
  $pages = file_get_contents('pages/1.php'); //like this?


 break;

 case "faq":
  $content = file_get_contents('faq.php');


 break;


 default:
  $content = file_get_contents('home.php');
 break;
}
?>

//some code

<?php echo $content; ?>

//some code

the home php:

<?php
switch($_GET['page'])
{
        default:
 case "1":
  $page = file_get_contents('pages/1.php');
 break;



 default:
  $page = file_get_contents('pages/1.php');
 break;
}
?>

// some code

<?php echo $page; ?>

//some code

go to page etc.

but when i do it like this the echo command shows me the code of the home.php but not the one of the page i wanna load inside of it. i appreciate any kind of help!

  • 写回答

4条回答 默认 最新

  • dongnan1989 2010-12-08 15:54
    关注

    Try using include() instead.

    Also, as @Rob said, your second switch() statement is ill formatted. default: should always be last and is used as a "catch-all" for values you didn't specify earlier.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向