php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71098 "return" can't be used after "or"
Submitted: 2015-12-11 22:20 UTC Modified: 2016-06-23 23:37 UTC
From: admin at mvpro dot net Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: Irrelevant OS: Any
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: admin at mvpro dot net
New email:
PHP Version: OS:

 

 [2015-12-11 22:20 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-23 23:37 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Package: *General Issues +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2016-06-23 23:37 UTC] cmb@php.net
Duplicate of request #31627.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 22 15:01:24 2020 UTC