php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47348 (print('') && false) returns int(1)
Submitted: 2009-02-09 13:58 UTC Modified: 2009-02-10 21:13 UTC
From: brunner dot adam at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2CVS-2009-02-09 (snap) OS: debian linux
Private report: No CVE-ID: None
 [2009-02-09 13:58 UTC] brunner dot adam at gmail dot com
Description:
------------
"print('') && false" returns integer 1, but "false && print('')" and "(int)1 && false" returns false

Reproduce code:
---------------
<?php
var_dump((print('') && false)); // int(1)
?>


Expected result:
----------------
returns bool(false)

Actual result:
--------------
return int(1)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-09 14:59 UTC] scottmac@php.net
print is a language construct and not a function and since the parenthesis are optional its really:

print '' && false

Where the second expression is considered part of the first.
 [2009-02-10 21:13 UTC] brunner dot adam at gmail dot com
Thanks, and you're right. This behaviour is described in the manual at include's page. But bit confusing, that -- still if it's optional -- I 
put the parenthesis, why would not "use" them?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 02:01:29 2024 UTC