?
Solved

PHP - Does php have "Select case" like asp has?

Posted on 2003-03-24
8
Medium Priority
?
202 Views
Last Modified: 2008-03-06
Ok, this is how I have done this in ASP:

**********************************************************
functions.asp

<%

SELECT CASE Request.Querystring("link")
     CASE "frontpage":
          %><!--#include file="frontpage.asp"--><%

     CASE "aboutme":
          %><!--#include file="aboutme.asp"--><%

     CASE Else:
          %><!--#include file="frontpage.asp"--><%

End SELECT
%>




**********************************************************
index.asp


    <TABLE BORDER="1">

     <TR>
     <TD><A HREF="index.asp?link=frontpage">Frontpage</A> <BR>
            <A HREF="index.asp?link=aboutme">aboutme</A> <BR></TD>

     <TD><BR><!--#include file="functions.asp"--></TD>
    </TR>

   </TABLE>



**********************************************************


So when I click the link "aboutme", in functions.asp the page will change to aboutme.asp
And whole site will not load again, only the center, the main thing where all stuff is.
All links and banners loads just once. Understand? Good.

Now do it on PHP.
Thanks
Regards, excii

0
Comment
Question by:excii
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:wide_awake
ID: 8198459
switch($var)
{
case 'frontpage':
     ?>frontpage<?
     break;
case 'aboutme':
     ?>aboutme<?
     break;
default:
     ?>other<?
     break;
}
0
 
LVL 1

Accepted Solution

by:
Kriek earned 200 total points
ID: 8199138
For the sake of matching your example in ASP I will discard defining the variables, lol. Would a moderator please delete my previous comments?

<?php
    switch ($_GET['link']) {
        case "frontpage": include('frontpage.php');
        break;
        case "aboutme": include('aboutme.php');
        break;
        default: include('frontpage.php');
        break;
    }
?>



0
 

Expert Comment

by:Chmod
ID: 8199334
Question tidied as requested in http://www.experts-exchange.com/Community_Support/Q_20561679.html

Chmod
Community Support Moderator @Experts Exchange
0
 

Author Comment

by:excii
ID: 8202909
what is that "break;" meaning?
0
 
LVL 1

Expert Comment

by:Kriek
ID: 8203043
Via the Manual: Break ends execution of the current for, foreach while, do | while or switch structure. Break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.



0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question