|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23400 "print(2 or 3)" returns wrong result
Submitted: 2003-04-29 02:29 UTC Modified: 2003-04-30 02:43 UTC
From: akukula at min dot pl Assigned:
Status: Not a bug Package: *Programming Data Structures
PHP Version: 4.3.1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: akukula at min dot pl
New email:
PHP Version: OS:


 [2003-04-29 02:29 UTC] akukula at min dot pl
Bash command line:
$ echo '<?php print(2 or 3) ?>' | php
The result is 1
$ echo '<?php $i = 2 or 3; print($i) ?>' | php
The result is 2
According to documentation (e.g. the chapter on operators)
it should return '2' in both examples.

Kind regards,
Andrzej Kukula


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-29 10:39 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

This is definately not bug. 
 [2003-04-30 02:43 UTC] akukula at min dot pl
Okay, sorry for the mistake, I have misunderstood that "or" returns it first or second argument instead of true/false. This is my mistake. Please close that bug.

Besides, it's a pity that there's no operator that allows me to:
$var = $user_entered_value or "default";

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Sep 29 19:05:54 2022 UTC