CKTIS / PHP
Keyword if
Execute a branch when its condition converts to true.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
if ($condition) { /* statements */ }Execute a branch when its condition converts to true. The exact strings "" and "0" are false-like, whereas "00" and "false" are true-like. Use a strict comparison when a text flag has a specific accepted spelling.
$active=[];
foreach(["","0","00","false"] as $flag){if($flag){$active[]=$flag;}}
echo json_encode($active);
["00","false"]
Examples
<?php
$active=[];
foreach(["","0","00","false"] as $flag){if($flag){$active[]=$flag;}}
echo json_encode($active);
Result
["00","false"]