如何实现这个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&2Therefore, 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; }更多推荐
发布评论