I have a switch problem. The code is below. The problem is that the inner switch (but not the outer one) doesn't evaluate, defaulting to the last option, rather than choosing the first, as expected. I'm running 4.3 as on Windows with recent version of Apache ... but the same error occurs on a *nix machine with earlier versions of both.

Only one case is shown below, but the rest of them are the same.

Any ideas? I've tried everything I can think of ... and ZDE isn't catching any bugs.

isset($_GET['lang']) ? $lang = $_GET['lang'] : $lang = 'en';
isset($_GET['page']) ? $page = $_GET['page'] : $page = 'home';

switch($lang)
{
	case 'en' :
		include 'enHeader.html';
		switch ($page)
		{
		case 'home' : $currentPage = "home.html";
		case 'about' : $currentPage = "enAbout.html'";
		case 'services' : $currentPage = "enServices.html";
		case 'portfolio' : $currentPage = "enPortfolio.html";
		case 'webmail' : $currentPage = "webmail.html";
		case 'contact' : $currentPage = "enContact.html";
		}

	include $currentPage;
	include 'footer.html';
	break;

    try inserting a break statement at the end of each case (as you do it in the outer switch construct), else all following cases will be executed, too, thus overwriting your variable.

      no need to be 🙂
      glad I could help you.

        Write a Reply...