switch statement problem

I’m trying to build a navigation using php switch, this shouldn’t be a problem, I’m including a simple statement as follows:

<?php switch ('$page') { case 'home': include ('home.php'); break; case 'music': include ('music.php'); break; case 'staff': include ('staff.php'); break; case 'store': include ('store.php'); break; case 'contact': include ('contact.php'); break; case 'sneak_peek': include ('sneak_peek.php'); break; default: include ('home.php'); } ?>

For some reason, it doesn’t return any errors, it doesn’t do ANYTHING at all actually. he navbar will show …/index.php?page=sneak_peek but it will still display the default… I’ve checked the syntax so many times, and I am not getting anything from firebug or anything. How am I screwing this up? I am certainly no PHP expert, in-fact I’m quite the contrary, but… I’ve tried everything I can find, and no dice. I normally refuse to make my failures anyone else’s problem to solve, but this is for a project with a deadline and I am totally stumped.

Regards

If you put a php variable ($page in this case) inside single quotes, it will take it as a string. So kindly remove the quotes.

Sponsor our Newsletter | Privacy Policy | Terms of Service