00001 <?php
00013 define('CHOICE',"abcd");
00014
00015
00020 function main()
00021 {
00022
00023
00024 $choice1=CHOICE;
00025 switch($choice1)
00026 {
00027
00028
00029
00030
00031 case 1:
00032 case 2:
00033 echo 'A. $choice1 is either 1 or 2, that is ' . $choice1;
00034 break;
00035
00036 case "abcd":
00037 echo 'A. PHP switch case can accept string constants as case values';
00038 break;
00039
00040 default:
00041 echo 'A. If nothing else matches, there is always default :)';
00042 break;
00043 }
00044
00045 echo "<br/>\n<br/>\n";
00046
00047
00048
00049
00050
00051 switch((string)$choice1)
00052 {
00053 case "0":
00054 echo "B. Zero";
00055 break;
00056
00057 case "1":
00058 case "2":
00059 echo 'B. $choice1 is either 1 or 2, that is ' . $choice1;
00060 break;
00061
00062 case "abcd":
00063 echo 'B. PHP switch case can accept string constants as case values';
00064 break;
00065
00066 default:
00067 echo 'B. If nothing else matches, there is always default :)';
00068 break;
00069 }
00070
00071 }
00072
00073
00074 main();
00075
00076 ?>