String compare with if statement : String Compare « String « PHP






String compare with if statement

<html>
<head>
<title>Decisions</title>
</head>
<body>
<?php
     $str_ctrl_flow = "go";
   
     if(!strcmp($str_ctrl_flow, "go")) {
          print("string is \"go\"<br />");
     } else {
          print("Time to stop<br />");
          exit;
     }
   
     $str_ctrl_flow = "stop";
   
     if(!strcmp($str_ctrl_flow, "go")) {
          print("string is \"go\"<br />");
     } else {
          print("Time to stop<br />");
          exit;
     }
?>
</body>
</html>
           
       








Related examples in the same category

1.String compare demo: =
2.String compare: equal
3.strcasecmp: Binary safe case-insensitive string comparison
4.Compare string