if ( $user_is_admin && delete_record() ). On one visit, $user_is_admin holds false, and delete_record() never runs at all, not just untrue, never even called. Why would PHP skip running part of a condition entirely, instead of checking every part of it every time?&& short-circuits. The moment the left side, $user_is_admin, is false, PHP already knows the whole combined condition must be false, no matter what the right side would have produced, so it never bothers to run the right side at all. This matters specifically when the right side is a function call with its own side effects, such as deleting something, because that function's own code, not just its true-or-false answer, may never execute on some visits.if statement runs the block that follows it only when its condition evaluates to true. Pairing it with else gives a program a second block to run instead, for every other case, with no condition of its own needed on the else branch.elseif lets a program check several conditions in a strict order, top to bottom, stopping at the very first one that turns out true. Every later elseif and the final else, if there is one, are skipped completely once an earlier branch has already matched.==, ===, <, and >=, each produce a boolean, true or false. A condition is, underneath everything else, always just one boolean value that PHP checks at the moment the if line runs.&& (and), || (or), and ! (not) combine or flip boolean values to build a more complex condition out of simpler ones, the same way arithmetic operators combine numbers.if ( $is_member ), with no == anywhere, is a complete, valid condition on its own, because $is_member already holds a true-or-false-like value PHP can check directly.elseif branches top to bottom, stopping at the first one whose condition is true. Rearranging the order of these specific branches would change which price some ages receive, even though each individual condition's text stays exactly the same.$age >= 65 && $is_member requires both sides to be true for this branch to run. If $age is 70 but $is_member is false, this whole elseif is skipped, and PHP moves on to check the next elseif, $is_member, which is also false here, so it falls through to else.70 and true passed into the call never get compared to anything by name. Inside the function, they are simply whatever $age and $is_member happen to equal for this one call. A different call elsewhere, with different values, runs the exact same function logic completely independently.return ends ticket_price() the instant any one branch's return line runs. Even though four return statements exist in this one function, exactly one of them ever executes per call.if, elseif, or else blocks themselves, only the lines inside them, such as return 0;, end with one. A block inside { } is a compound statement, not the kind of single line a semicolon is needed for.$age >= 65 && $is_member branch and the $is_member branch in this exact function means every 70-year-old member receives 6, the ordinary member price, instead of 4, the senior member price, even though neither condition's text changed at all.$is_logged_in && load_user_profile(), the function load_user_profile() is never called at all when $is_logged_in is false, because && already knows the overall result without checking further. Relying on that function running as a side effect, rather than only for its true-or-false answer, is a common source of bugs that only appear for logged-out visitors.if statements back to back, instead of if and elseif, means PHP evaluates both conditions independently, and can run both blocks on the same request if both happen to be true together, instead of running at most one block the way a single if/elseif/else chain guarantees.0, "", "0", null, an empty array, and false itself as false-like inside a condition, and every other value, including the actual text "false", as true-like. This is why if ( "false" ) runs its block.! ($age >= 65 && $is_member) flips the truth of the whole combined expression at once, because of the parentheses. Writing ! $age >= 65 && $is_member instead only negates $age by itself, turning it into a boolean before comparing that to 65 at all, producing a result that is almost never what was intended.elseif, not separate stacked if statements, whenever only one branch is meant to run. Second, does it ever place a function call purely for its side effect inside && or ||, where that call might silently never run. Third, does it use === rather than == when checking against specific values such as 0 or an empty string, given how many things compare loosely equal to false.is_open( $hour ) that returns true only when $hour is 9 or later and earlier than 17, using a single && inside one if.if ( "false" ) does, as a stand-in condition, before running it, then check the prediction.if ( $age = 70 ) (assignment) instead of if ( $age == 70 ) (comparison) inside a decision chain, silently overwriting $age with 70 for every visitor regardless of their real age, then comparing the freshly assigned value to itself.elseif and writing if, if, if instead, allowing two unrelated branches to run on the very same request when both of their conditions happen to be true together.== 0 check, then being surprised when an empty string or null also satisfies that same check.else always pairs with the nearest if written above it, no matter what, when careless brace placement, or a skipped pair of braces on a single-line if, can attach an else to the wrong if entirely.Welcome back to Jit4All