| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jan 2008
Posts: 55
|
The switch statement and PHP 5....
I have a website that is currently working perfectly on a PHP 4 server. I recently upgraded to PHP 5 and tested the site but only in vain. It seems that 5 is not picking up on the switch statement. I used the switch statement to make the "switch" for the content while keeping my template (index page) in order. I have two computers so I went back to PHP 4 on one and using 5 in the other It all work in 4 but 5...not so much. Can anyone tell me what happened and what can I do to make this work in 5? I hope my explanation was clear. Thanks, Will |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Jan 2008
Posts: 55
|
My Apologies.. PHP Code:
My menu is as follows..... HTML Code:
Thanks for the help.... Last edited by hollywooood : 06-05-2008 at 03:21. |
|
|
|
#5 (permalink) |
|
shiro
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 1,306
|
freelancr was right without even seeing the code. Nice one! Hollywood: You need to change this line: Code:
to this: Code:
This is not a signature.
|
|
|
|
#7 (permalink) |
|
Grumpy old man
Join Date: Oct 2007
Location: North Japan
Posts: 1,128
|
What's going on with the default case? Firstly it has no break; so I think anything which takes the default branch will trickle down into the about case. Then you seem to have several redundant lines of code at the bottom of the switch without a case (is that supposed to be the default branch?) Presumably you make the assignment to $page somewhere else in the code? Just a couple of other observations - why not use single quotes for the $css = '...' - then you don't need to escape every occurrence of double quotes: $css = '<link href="iestyle.css" rel="stylesheet" type="text/css" />'; is a lot more readable than: $css="<link href=\"iestyle.css\" rel=\"stylesheet\" type=\"text/css\" />"; Also, I think it's good practice to quote strings, even though in a case statement you aren't forced to. Again it makes the code clearer. Although since you use ternary form for your conditional, I guess clarity isn't a big concern for you. Edit: I love it when someone else answers between starting and finishing a comment |
|
|
|
#11 (permalink) |
|
Moderator
Join Date: Jan 2005
Location: Brooklyn, NYC
Posts: 11,869
|
Better get ready, PHP6 is coming out this year last I heard! Find good advice in the beginners web design thread.
patrick o'neill web developer | blog | spam humor |
|
|
|
#12 (permalink) |
|
Registered User
Join Date: Jan 2008
Posts: 55
|
PGO...What do you recommend the best way to learn the in and outs of PHP. I live in Indonesia where information is not easily come by. I think I should be able to get what I need off the net but what and who can give me the best materials to learn it? Appreciate any suggestions. |
|
|
|
#13 (permalink) |
|
Grumpy old man
Join Date: Oct 2007
Location: North Japan
Posts: 1,128
|
Think of a problem and try to solve it. Search for solutions as you go. Rinse and repeat. Probably all you need to master a basic language like PHP is: 1. Basic syntax 2. Operators 3. Control structures 4. Defining classes and functions 5. Variables, arrays and variable scope You don't need to memorize every available function call or class method. That's why php.net has a reference. Having said that, it would be useful to at least have a working knowledge of the most commonly used functions (such as string functions) so you don't have to keep going to look them up. They'll come with time though. |
|
![]() |