如何实现这个Switch Case?(How to achieve this Switch Case?)

系统教程 行业动态 更新时间:2024-06-14 16:58:00
如何实现这个Switch Case?(How to achieve this Switch Case?)

基本上,我需要3个switch case脚本来浏览HTML页面,如下所示:

1st:<BR> index.php?1<BR> index.php?2<BR> index.php?3...

第二个(这个是子页面):

index.php?1&2

因此,举一个例子,第二个:我有几本书要放在网上,而index.php是主目录,那么index.php?1是目录中的第一本书,而index.php? 1&1是第一本书和第一章......

And the 3rd:<BR> **index.php?book_id=1** or<BR> **index.php?book_id=1&chapter_no=1**

这可以实现吗?

Basically, I would need 3 switch case scripts for navigation through HTML pages, like this:

1st:<BR> index.php?1<BR> index.php?2<BR> index.php?3...

2nd (this one is with subpages):

index.php?1&2

Therefore, an example, with the 2nd one: I have a few books that I want to put online and index.php is the main catalog, then index.php?1 is the first book in the catalog, and the index.php?1&1 is the first book and the first chapter in it...

And the 3rd:<BR> **index.php?book_id=1** or<BR> **index.php?book_id=1&chapter_no=1**

Is this achievable?

最满意答案

你可以做到这一点:

switch(true) { case $_SERVER['QUERY_STRING']=='1' : include("PAGETOINCLUDE1"); break; case $_SERVER['QUERY_STRING']=='1&2' : include("PAGETOINCLUDE2"); break; case $_SERVER['QUERY_STRING']=='book_id=1' : include("PAGETOINCLUDE3"); break; case $_SERVER['QUERY_STRING']=='book_id=1&chapter_no=1' : include("PAGETOINCLUDE4"); break; default: include("DEFAULTPAGE"); break; }

you can do this trick :

switch(true) { case $_SERVER['QUERY_STRING']=='1' : include("PAGETOINCLUDE1"); break; case $_SERVER['QUERY_STRING']=='1&2' : include("PAGETOINCLUDE2"); break; case $_SERVER['QUERY_STRING']=='book_id=1' : include("PAGETOINCLUDE3"); break; case $_SERVER['QUERY_STRING']=='book_id=1&chapter_no=1' : include("PAGETOINCLUDE4"); break; default: include("DEFAULTPAGE"); break; }

更多推荐

本文发布于:2023-04-14 05:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/b064c85d6114098f2788d73624cd9b4f.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何实现   Switch   achieve   Case

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!