niklasvh / php.js

PHP to JavaScript converter and VM written in JavaScript
http://phpjs.hertzen.com
MIT License
860 stars 115 forks source link

Support for Closures #38

Open adamjimenez opened 11 years ago

adamjimenez commented 11 years ago

This valid code (from http://php.net/manual/en/functions.anonymous.php):

function ($quantity, $product) use ($tax, &$total)
{
    $pricePerItem = constant(__CLASS__ . "::PRICE_" .
        strtoupper($product));
    $total += ($pricePerItem * $quantity) * ($tax + 1.0);
}; 

Gives this error:

Parse error: syntax error, unexpected T_STRING, expecting identifier in /console.htm on line 2