note 90618 modified in control-structures.switch by danbrown

From: Date: Thu, 30 Apr 2009 16:50:56 +0000
Subject: note 90618 modified in control-structures.switch by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154055@lists.php.net to get a copy of this message
Its weird but when I dont add break; after switch{} statement, page keeps reloading (twice in my case). This example keeps reloading the page and switch statement again: <?php $op="sponsor"; switch($op) { case "sponsor": echo"sponsor"; break; default: include("index.php"); break; } ?> this double echos sponsor! if I add a break after the switch then it really breaks! <?php $op="sponsor"; switch($op) { case "sponsor": echo"sponsor"; break; default: include("index.php"); break; } break; ?> This would be helpfull if you navigate your site by switch funtion and you need to include a case into a div via ajax. --was-- Its weird but when I dont add break; after switch{} statement, page keeps reloading (twice in my case). This example keeps reloading the page and switch statement again: $op="sponsor"; switch($op) { case "sponsor": echo"sponsor"; break; default: include("index.php"); break; } this double echos sponsor! if I add a break after the switch then it really breaks! $op="sponsor"; switch($op) { case "sponsor": echo"sponsor"; break; default: include("index.php"); break; } break; This would be helpfull if you navigate your site by switch funtion and you need to include a case into a div via ajax. http://php.net/manual/en/control-structures.switch.php

« previous php.notes (#154055) next »