Req #71098 [Opn->Dup]: "return" can't be used after "or"

From: Date: Thu, 23 Jun 2016 23:37:59 +0000
Subject: Req #71098 [Opn->Dup]: "return" can't be used after "or"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201817@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71098&edit=1

 ID:                 71098
 Updated by:         cmb@php.net
 Reported by:        admin at mvpro dot net
 Summary:            "return" can't be used after "or"
-Status:             Open
+Status:             Duplicate
 Type:               Feature/Change Request
-Package:            *General Issues
+Package:            Scripting Engine problem
 Operating System:   Any
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Duplicate of request #31627.


Previous Comments:
------------------------------------------------------------------------
[2015-12-11 22:20:47] admin at mvpro dot net

Description:
------------
"return" can't be used after "or". I think it's strange because
"die" for example can be used after "or".

Test script:
---------------
<?php

function connect()
{
	mysql_connect('localhost', '', '') or return false;
	return 1;
}

$connect = connect();
if( $connect == 1)
	echo 'Successfully connected';
else
	echo 'Connect failed!';

Expected result:
----------------
Connect failed!

Actual result:
--------------
Parse error: syntax error, unexpected 'return' (T_RETURN) on line 5
https://3v4l.org/3qAYN


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71098&edit=1


Thread (2 messages)

« previous php.bugs (#201817) next »