# PHP : switch

**URL:** <https://forum.kirupa.com/t/php-switch/164671>\
**Category:** programming\
**Created:** [October 3, 2005, 11:03pm UTC](https://forum.kirupa.com/t/php-switch/164671 "2005-10-03T23:03:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dinkumrocks](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dinkumrocks](https://forum.kirupa.com/u/dinkumrocks)\
**Post date:** [October 3, 2005, 11:03pm UTC](https://forum.kirupa.com/t/php-switch/164671/1 "2005-10-03T23:03:19Z")

</div>

Hey guy. Im learning php, it seriously kicks…

I’m having a problem witht he switch() function though. It’s like it’s not recognizing the ‘default’ case. this is what i have…

$x = $\_GET[‘x’];  
switch($x) {  
case 1:  
echo “1”;  
break;  
case 2:  
echo “2”;  
break;  
case 3:  
echo “3”;  
break;  
default:  
echo “default”;  
}

but it gives me this error…

**Notice** : Undefined index: x in **c:\Inetpub\wwwroot\adcore emp\_site.php** on line **10**  
default

line 10 being -\>$x = $\_GET[‘x’];

anyone? thank,  
-Naaman
