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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 14:01:27 2024 UTC