Req #31627 [Com]: return statement should return

From: Date: Wed, 12 Mar 2014 08:40:40 +0000
Subject: Req #31627 [Com]: return statement should return
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184738@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=31627&edit=1 ID: 31627 Comment by: asphp at dsgml dot com Reported by: mnemo at minimum dot se Summary: return statement should return Status: Open Type: Feature/Change Request Package: Scripting Engine problem Operating System: * PHP Version: * Block user comment: N Private report: N New Comment: binarycleric - that doesn't do the same thing in the slightest. That would cause the return to run either way. What mnemo wants is for the return to happen ONLY if mysql fails. Otherwise it should continue to the next line. This works: function foo() {} mysql_connect(blah) or foo(false); But this doesn't: mysql_connect(blah) or return(false); And I think it should. Previous Comments: ------------------------------------------------------------------------ [2011-07-20 23:36:12] binarycleric at gmail dot com That really isn't what return does because it's not a conditional. Similar behaviour can be achieved by using: return (mysql_connect($blah) !== false) ? true : false; ------------------------------------------------------------------------ [2005-01-20 19:28:40] mnemo at minimum dot se Description: ------------ I wish "return doh" was treated like an expression when though this expression will never be computable. The reason is that I want to write this: mysql_connect(blah) or return false; Just like I do with die etc. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=31627&edit=1

« previous php.bugs (#184738) next »