php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
27 + 14 = ?
Subscribe to this entry?

 
 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-29 10:39 UTC] sniper@php.net
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 http://www.php.net/support.php 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";
...

Regards,
Andrzej
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 10:01:29 2024 UTC