Monday, 30 September 2013

PHP string comparasion

PHP string comparasion

I have a variable and its type is string. var_dump() shows:
var_dump() output is below:
string(14)
//this is my code..
$game_cat = "Some text"; // some text mean actually it is one of below
Category 1,2,3,4 ...
if ( $game_cat === "Category 1" ) {
$cid = 1;
}
if ( $game_cat === "Category 2" ) {
$cid = 2;
}
if ( $game_cat === "Category 3" ) {
$cid = 0;
}
else{
$cid = 999999;
}
For example when I change $game_cat to Category 1 like $game_cat =
"Category 1"; $cid must 1 but output is 999999.
Why?

No comments:

Post a Comment