I am trying to get \"OK\" if my condition False, i want to keep same if else order as given example, don\'t advice to move \"else\" content in \"if\" and \"if\" content in \"els
I tested this code and it works.
if(!($flag != 0 || $point >= 1000)){
echo "Not OK";
}else{
echo "OK";
}
After reading your comments:
It seems you want to show some score (in the else-branch of an if-then-else) if the user has equal/more than 1000 points or you toggle a flag (which basically means "always show points").
Normally you'd be doing that in the if-branch:
if ($flag || $point >= 1000)
{
echo "OK";
} else {
echo "Not OK";
}
Since you want the Not OK
to be in the if-Branch you need to inverse the condition, doing so means inverting every part of the condition and the operators aswell:
$flag
becomes !$flag
$point >= 1000
becomes $point < 1000
||
becomes &&
Result:
if (!$flag && $point < 1000)
{
echo "Not OK";
} else {
echo "OK";
}
Writing this into a truth-table:
flag point result
0 < 1000 Not OK
1 < 1000 OK
0 >=1000 OK
1 >=1000 OK