Why i dont get output okok in bellow example ? <?php $site = "wp_cont|jqu"; if (strstr($site, "wp_cont") == TRUE) { $x = "ok"; } if(strstr($site, "jqu") == TRUE) { $x = "ok"; } echo $x; PHP:
Because, when the second if condition matches, it would overwrite the $x variable. If you used the concatenation, it would have worked: <?php $site = "wp_cont|jqu"; if (strstr($site, "wp_cont") == TRUE) { $x = "ok"; } if(strstr($site, "jqu") == TRUE) { $x .= "ok"; } echo $x; PHP: See that dot(.) operator used in the above code.