Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

Logical disjunction (or)

The word `or` checks the second possibility only when the first is false-like.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

($first or $second)

The word or checks the second possibility only when the first is false-like. Assignment binds more tightly and can store the first value before the second one is tested. Enclose the whole expression in parentheses to store the combined boolean result.

($first or $second)

[false,true]

Examples

<?php
$partial = false or true;
$complete = (false or true);
echo json_encode([$partial,$complete]);

Result

[false,true]

Sources