Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-24
8
Medium Priority
?
203 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
5 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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
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

578 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