php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53896 return/break types "if"
Submitted: 2011-02-01 05:39 UTC Modified: 2011-02-01 05:42 UTC
From: david71rj at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.3.5 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david71rj at gmail dot com
New email:
PHP Version: OS:

 

 [2011-02-01 05:39 UTC] david71rj at gmail dot com
Description:
------------
It's a simple feature that PHP can have, if just substitute if+return, for 
instance to return+if. It's, change to one-line script.

See test script and read more...

Well, sometimes we need to break function, or while, or foreach, or maybe force 
continue case somethink occur, a condition.

My idea is make this more readable, in an one line script.

Instead of:
if($a < $b) return;

We do:
return if $a < $b;

Or:
return if($a < $b);

Maybe only accept a boolean on return:
return $a < $b;

Then:
return true; // do "return"
return false; // not do

Same to continue:
for($i=0; $i<10; $i++){
  continue $i === 5;
  echo $i . "\n";
}

It's a valid idea? ^o)
Bye.

Test script:
---------------
http://pastebin.com/fEB8eGxf


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-01 05:42 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2011-02-01 05:42 UTC] aharvey@php.net
PHP is not Perl, and doesn't support postfix statement modifiers. This is intentional, and unlikely to change.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 17:01:33 2025 UTC