php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74115 and/or documented to be bool but int and/or int is int
Submitted: 2017-02-17 03:36 UTC Modified: 2017-02-17 08:43 UTC
From: nick at lampnick dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.6.30 OS: windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nick at lampnick dot com
New email:
PHP Version: OS:

 

 [2017-02-17 03:36 UTC] nick at lampnick dot com
Description:
------------
---
From manual page: http://php.net/manual/en/language.operators.logical.php
---
$a and $b	And	TRUE if both $a and $b are TRUE.
$a or $b	Or	TRUE if either $a or $b is TRUE.
The 'and' and the 'or' is use for bits,but this doc use for Logical.

Test script:
---------------
<?php
$a = 4;
$b = 1;
$res1 = $a and $b;
$res2 = $a & $b;
$res3 = $a or $b;
$res4 = $a | $b;
var_dump($res1);//the res1 is 4,but the manual describes the result to be a bool type.
var_dump($res2);
var_dump($res3);
var_dump($res4);

Expected result:
----------------
$a & $b	And	Bits that are set in both $a and $b are set.
$a | $b	Or (inclusive or)	Bits that are set in either $a or $b are set.

Actual result:
--------------
$a and $b	And	TRUE if both $a and $b are TRUE.
$a or $b	Or	TRUE if either $a or $b is TRUE.

Patches

fixedLogicalOperatorsdocs (last revision 2017-02-17 03:40 UTC by nick at lampnick dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-17 08:43 UTC] requinix@php.net
-Summary: This doc has some error descriptions. +Summary: and/or documented to be bool but int and/or int is int -Status: Open +Status: Not a bug -Package: Documentation problem +Package: Variables related
 [2017-02-17 08:43 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/manual/en/language.operators.precedence.php
= has higher precedence than and/or.

https://3v4l.org/oTgLQ
https://3v4l.org/2J1kI
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 27 03:01:30 2024 UTC