I have this code in one of my functions:
$condition = 1;
$bool = false;
$strict = false;
switch($condition):
case "true":
case "1":
if($strict == false):
if($value == true)$bool = true; //only works when if opened with ":" and closed with endif;
else:
if($value === true)$bool = true; //same applies here
endif;
break;
case "ntrue":
case "-1":
if($strict == false):
if($value != true)$bool = true; //same applies here
else:
if($value !== true)$bool = true; //same applies here
endif;
break;
endswitch;
The above code will produce parse error "unexpected ':'" on every "else:" line. Can I use opened if statements in switch loop (although it doesn't work if I close it with "{}" either) and if I can, what is happening there what makes the parsing error?
Aucun commentaire:
Enregistrer un commentaire