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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 21:01:29 2024 UTC