php - Why is $x a undefined variable for switch statement? -


it display $x undefined. wrong switch statement?

http://localhost/add.php?price_error=1 switch(isset($_get['price_error']) && $_get['price_error'] == $x){ case 1: echo '<span class="error_msg">discount price cannot greater original price</span><br/>'; break; case 2: echo '<span class="error_msg">discount cannot less 30% of original price</span><br/>'; break; case 3: echo '<span class="error_msg">discount price , original price cannot greater $30000 hkd</span><br/>'; break; default: false; break; } 

switches typically have variable parameters.

try:

if(isset($_get['price_error']) && $_get['price_error'] == $x){ switch($x){ //code } } 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -