|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50515 return() in short-circuit / lazy evaluation
Submitted: 2009-12-18 10:26 UTC Modified: 2009-12-18 11:20 UTC
From: ntpt at seznam dot cz Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.12 OS: linux
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.
Block user comment
Status: Assign to:
Bug Type:
From: ntpt at seznam dot cz
New email:
PHP Version: OS:


 [2009-12-18 10:26 UTC] ntpt at seznam dot cz
please allow return() in lazy evaluation /short-circuit syntax like

$result=do_something($blah) or die('nothing done'); // this works


$result=do_something($blah) or return(false) ; // does NOT work

I thing it is prety legitimate not only to call die() if do_something() return false, but in this case return() from function or include() as well. I thing it is more cleaner and readable then bunch of

if ($result==false){
return false;}
// use you result here

Maybe even codeblock after "or" is worth of considerations

$result=do_something($blah) or { // codeblock, do what you want here 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-18 11:20 UTC]
Never happens.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 25 05:03:35 2022 UTC