Re: How to recognize which 'case' is being echoed by switch statement
| From: | Stut | Date: | Fri, 22 Feb 2008 12:31:27 +0000 |
| Subject: | Re: How to recognize which 'case' is being echoed by switch statement | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-44641@lists.php.net to get a copy of this message | ||
On 22 Feb 2008, at 11:01, Tim Daff wrote:
$page = case; will be raising a notice which you're obviously not seeing. So, step 1 is to edit PHP.ini on your development machine so error_reporting is E_ALL, and display_errors is on. You'll need to restart your web server for this change to take effect. The case keyword is not valid outside a switch block. What you want to be doing is comparing "contact" etc with $_GET['page'] which is the variable the switch statement is using. Additionally you are using a single = which is the assignment operator, so each if statement is assigning the quoted string to $page not testing for it. You need to use == to do that. I would suggest you buy a book on PHP for beginners, or Google for an introductory tutorial because these are pretty basic syntax mistakes. -Stut -- http://stut.net/<?php$page = case; if ( $page = "contact" ) { echo "<li id=\"contact-active\"></li>"; } else { echo "<li id=\"contact\"><a href=\"./?page=contact\">Contact</a></li>"; } ?>