<?php
$key = "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK";
$pass = "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK";
if ( strcasecmp( $_GET['pass'], $pass ) == 0 ) {
echo($key);
}
?>
switch( $_GET['pass'] )
{
// ...
}
The case expression may be any expression that evaluates to a simple type, that is, integer or floating-point numbers and strings. Arrays or objects cannot be used here unless they are dereferenced to a simple type.
Arrays are always converted to the string «Array»; because of this, echo and print can not by themselves show the contents of an array.
$testArray = array('BBB', 'BBB');
$array1 = array('AAA', 'AAA');
$array2 = array('BBB', 'BBB');
switch($testArray) {
case $array1:
echo 'First<br />';
case $array2:
echo 'Second<br />';
}
switch( $_GET['pass'] )
{
case "foo":
echo 'foo';
break;
case "bar":
echo 'bar';
break;
default:
echo 'no matches';
}
// output: "foo"