Doc #74550 [Opn->Nab]: Illegal behaviour in booleans

From: Date: Sat, 06 May 2017 13:18:00 +0000
Subject: Doc #74550 [Opn->Nab]: Illegal behaviour in booleans
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14675@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74550&edit=1 ID: 74550 Updated by: nikic@php.net Reported by: lee dot traynor at skeptic dot de Summary: Illegal behaviour in booleans -Status: Open +Status: Not a bug Type: Documentation Problem -Package: PHP Language Specification +Package: Scripting Engine problem Operating System: Windows 10 PHP Version: 7.0.18 Block user comment: N Private report: N New Comment: "and" has lower precedence than "=", so this expression is interpreted as ($ctm = true) and (false or false). See http://php.net/manual/en/language.operators.precedence.php for the operator precedence table. You are looking for && and ||. Previous Comments: ------------------------------------------------------------------------ [2017-05-06 13:11:44] lee dot traynor at skeptic dot de Description: ------------ --- From manual page: http://www.php.net/language.types.boolean --- Evaluation of boolean expressions leads to conflicting (and incorrect) results. Test script: --------------- $ctm = true and (false or false); var_dump ($ctm, true and (false or false)); returns true, false Expected result: ---------------- Should return false, false, and does in fact return this if the expression that is assigned to $ctm is enclosed in brackets. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74550&edit=1

« previous php.doc.bugs (#14675) next »