Edit report at http://bugs.php.net/bug.php?id=52432&edit=1

 ID:                 52432
 Updated by:         ka...@php.net
 Reported by:        halloanjedendenichkenne at gmail dot com
 Summary:            {} with Return Value
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   Irrelevant
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        kalle
 Block user comment: N

 New Comment:

Closures here should really be enough for what you are trying to
achieve:

http://php.net/closures



As for the function-call-or-failure sample, if you really want such a
context then I do not see why you don't simply do:



if(!call(...)) {

        ...

]


Previous Comments:
------------------------------------------------------------------------
[2010-07-25 02:09:41] halloanjedendenichkenne at gmail dot com

Description:
------------
It would be pretty cool if you were able to use { CodeHere; } as
Statement.

The Basic Idea behind this is like if the Code was a Function that had a
Return 

Statement. Its only a little inefficient because the Function might only
be used 

one Time, which means it would be useful to have such a Feature.



Examples are given in the TestScript

Test script:
---------------
<?php



  //1.

  if({

    $a = false;

    $b = true;

    return (time() % 2) && $b || $a;

  }) echo 'It equals to True';



  //2.

  mysql_connect(...) or {

    $file = fopen('ErrorLog', 'a+');

    ...;

    return die();

  };



  //3.

  $a = 12 + {

    return 2 * 2;

  };



?>

Expected result:
----------------
1. Depending on the Time echoing 'It equals to True';

2. When mysql_connect returns false that it evaluates the {}-Code

3. $a = 16;

Actual result:
--------------
Parse Error of course


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52432&edit=1

Reply via email to