[Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

Alexander Wagner waqner at gmx.net
Thu Jun 19 18:53:19 EDT 2008

On Wednesday 18 June 2008, Luke Palmer wrote:
> I don't know that much PHP, but I find the "lexical" keyword to be a
> nuisance.  What are the semantics if the lexical keyword is omitted? 

In PHP Variables are local by default, the keyword global defines them as 
references to the global namespace.
There are some exceptions, like the availability of $this in methods or a 
couple of predefined superglobal variables that are implicitly global in all 

$globalVar = 1;
$param = "notshared";
$localVar = "notshared";

function foo ($param) {
  global $globalVar;
  $localVar = (int) $param;
  return $localVar + $localVar;

Given how much it works like "global", the keyword "lexical" seems quite 
consistent with the style of PHP.


There’s a phrase we live by in America: “In God We Trust”. It’s right there 
where Jesus would want it: on our money.
 - Steven Colbert

More information about the Haskell-Cafe mailing list