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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
8 + 50 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 01:01:31 2024 UTC