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
 [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: Sat Dec 21 11:01:30 2024 UTC