Claudiu Persoiu

Blog-ul lui Claudiu Persoiu


Archive for the ‘closures’ tag

Closures, from Scheme to Javascript to PHP

without comments

The notion of closure in PHP, even though it appeared in PHP 5.3, as I’ve said before on my blog, it was properly done only in 5.4.

Wikipedia tells us:

In computer science, a closure (also lexical closure or function closure) is a function or reference to a function together with a referencing environment—a table storing a reference to each of the non-local variables (also called free variables) of that function.

In PHP this isn’t a very popular concept or very well-known. It is often mistaken for Anonymous Functions. But in functional programming languages it is very popular, because they really need it!

Scheme

When Brendan Eich designed JavaScript, relied on the Scheme language and ended up doing an implementation of this language with a C syntax. The C syntax was and is a lot more popular, and back then (1995) the Java programming language was very “fashionable”.

The Scheme syntax is similar to Lisp, in the sens that is using parenthesis abound expressions in order to execute them. The operators are defined as functions and just like them, there must be placed left of the parenthesis.

Let’s take an Scheme closure example:

(define (make-counter)
  (let ((count (begin 
                 (display "run parent function and return 0") 
                 0)))
    (lambda ()
      (set! count (+ count 1))
      (begin 
        (display "inside child function ") 
        count))))

The function is setting a “count” variable, with the value 0 and displays “run parent function and return 0”, then returns another lambda function, that is incrementing the variable defined in the main function and then displays “inside child function”.

I’m storing the resulting function in a variable in order to later run it multiple times:

> (define counter (make-counter))
run parent function and return 0
> (counter)
inside child function 1
> (counter)
inside child function 2

In other words, each time I’m calling (make-counter), it will return a new function that has access to the environment at the time at which it was created. If it looks strange because of the syntax, I promise that it will fell a lot more natural in JavaScript.

This concept is very interesting for encapsulation. The environment from the time when the parent function was been executed can be encapsulated, and later it can be used without worrying that it was changed by external causes.

For the functional programming languages this is a very interesting concept. Yet when it comes to object orientated languages, the concept seems almost useless, because objects also have the purpose of encapsulation.

JavaScript

From the beginning JavaScript was a hybrid, a functional programming language, object orientated, with prototype based inheritance. And if this wasn’t enough, the syntax was taken from Java (C).

JavaScript didn’t inherited a lot from Scheme, but it did inherit the closure concept.

A reason why there was a need for closures in Scheme is that that if a function is not finding a variable in its environment, it will search for it in its container’s environment. Let’s take an example:

(define x 1)
(define (add-in-env y) (+ x y))

If we call add-in-env with 2:

(add-in-env 2) -> 3

It looks just as ambiguous as in JavaScript, but is not exactly like that. In Scheme to do mutation is not that easy, simple and transparent, so an subsequent operation of:

(define x 2)

will result in an error.

In JavaScript resulted a hybrid. Mutation is permitted, but the notion of searching a variable in the current environment remained:

var x = 1;
var add_in_env = function (y) {
   return x + y;
}

add_in_env(2); // returns 3

Up to this point is ok, but for:

x = 2;
add_in_env(2); // returns 4

For this case, things can get out of hand very easy:

But, in order to solve the issue, we can just define a variable in the environment that will finish execution (will close):

var make_counter = function () {
   console.log("run parent function and set counter to 0")
   var count = 0;

   return function () {
       count = count + 1;
       console.log("inside child function");
       return count;
   }
}

var counter = make_counter();
console.log(counter());
console.log(counter());

var counter2 = make_counter();
console.log(counter2());
console.log(counter());
console.log(counter2());

The output will be:

run parent function and set counter to 0
inside child function
1
inside child function
2
run parent function and set counter to 0
inside child function
1
inside child function
3
inside child function
2

Even though the main function finished executing, the environment inside it is kept as a closure for the function that was returned. Only when there aren’t any more references to the sub-function the memory allocated for the closure will also be deallocated.

Even though JavaScript has objects, it doesn’t have private methods. An approach is to add a “_” (underscore) in front of the function name and consider it private. From my point is like asking the developers that will later use the code to consider this function private. Of course this is not very consistent.

Let’s take an example:

var obj = {
   _secretFunction : function (key) { console.log(‘do secret ’ + key) },
   doStuff : function (key) { this._secretFunction(key) }
}

obj.doStuff(‘stuff’); // do secret stuff

It seems that there is a public method “doStuff” and a private one “_secretFunction”. Nevertheless you can not prevent a user from calling “_secretFunction” or even worse, to modify it:

obj._secretFunction = function (key) { console.log('new secret ' + key); }

obj.doStuff('stuff'); // new secret stuff

If we want to hide the function, and make this obvious for everybody, again, we can use closures:

var obj = (function () {
   var secretFunction =  function (key) { console.log(‘do secret ’ + key) }

   return {
      doStuff : function (key) { 
         secretFunction(key) 
      }
   }
})();

obj.doStuff(‘stuff’); // do secret stuff

Because the parent function was not stored but rather immediately executed, basically the space in which secretFunction was defined has already finished its execution, encapsulating the logic. The object returned can call the function because it was defined in the same environment as the object.

Looks complicated at first, but is really very easy when you understand the concept.

And then it was… PHP

PHP includes a lot of different options. It was originally developed as a Perl framework, later the engine was rewritten in C.

PHP is a dynamic language that includes a lot of concepts, from objects, interfaces and anonymous functions, up to goto labels. The development direction for the language is not very clear, it rather offers the possibility for different approaches.

In the weird PHP history, somewhere in version 4, syntax for Anonymous Functions was added, but only in PHP 5.3 a more “normal” version appeared.

Also in version 5.3 the first closure version was introduced:

$scalar = 5;

$closure = function () use ($scalar) {
     return 'Scalar: ' . $scalar . PHP_EOL;
};

echo $closure(); // Scalar: 5

$scalar = 7;

echo $closure(); // Scalar: 5

This version mostly worked, but you had to specify what you want to send to the closure.

And there were other inconveniences:

<?php 
class Foo {         
   private function privateMethod() {                 
      return 'Inside private method';         
   }

   public function bar() {                 
      $obj = $this;                 
      return function () use ($obj) {                         
         return $obj->privateMethod();
      };
   }
}

$obj = new Foo();
$closure = $obj->bar();
echo $closure();

Fatal error:  Call to private method Foo::privateMethod() from context '' in [...][...] on line 10

Is not working because you can not send $this as a parameter to a closure, and if you try the above trick you still can’t access the private methods. Remember, this was happening in PHP 5.3.

The idea to introduce a closure of this kind seems strange to me. But this is not the first time something “strange” is introduced in PHP, as I was saying before about the Anonymous Functions. Sometimes is looking like work in progress.

I think everybody was expecting a more JavaScript like closures. I think that JavaScript had a big influence in making this concept so popular.

In version PHP 5.4 things changed, we finally have a closure as we would expect:

class Foo {
   private function privateMethod() {
      return 'Inside private method';
   }

   public function bar() {
      return function () {
         return $this->privateMethod();
      };
   }
}

$obj = new Foo();
$closure = $obj->bar();
echo $closure(); // Inside private method

And it works!

You can even do:

unset($obj);
echo $closure();

and it will work, because the object in which the closure was defined remains in memory until either the script finishes execution, or a call like this is made:

unset($closure);

For more details on how closures work in PHP 5.4, check out this post.

Written by Claudiu Persoiu

10 April 2013 at 10:02 AM

PHP 5.4 – Closures the right way!

with 5 comments

The concept of closure was introduced in PHP 5.3, with the new “more traditional” syntax for anonymous functions.

PHP 5.3

In PHP 5.3, a closure will rely on the term “use”, which was passing the variables to the anonymous function, making it a closure.

The problem is that the anonymous function will only be able to access the variables that have been passed with “use”. When it comes to objects, there are passed by reference by default, but scalar variables (int, string, etc.) are passed by value, as this is the default behavior in PHP 5+:

$scalar = 5;

$closure = function () use ($scalar) {
     return 'Scalar: ' . $scalar . PHP_EOL;
};

echo $closure(); // Scalar: 5

$scalar = 7;

echo $closure(); // Scalar: 5

Another problem is that you cannot pass $this when the anonymous function is declared inside an object, so only the public method and properties can be accessed inside the closure.

PHP 5.4

In PHP 5.4 the keyword “use” is optional, and the entire environment where the function was created is available inside the function.

The advantage is that when the anonymous function is created inside another function or method, the anonymous function has access to the environment where it was created, even after the execution of the environment is over. The objects from this environment will be unset, only after the last reference to the closure will be unset:

class testClass {

        private $changeableVar = 1;
        private $bigVar;

        public function __construct() {
                // Allocate a big variable so we can see the changes in memory
                $this->bigVar = str_repeat("BigWord", 5000);
        }

        /**
         * A method that returns the closure
         */
        public function closure() {

                return function () {
                        // Display the value of a private property of the object
                        echo 'Private property: ' . $this->changeableVar.PHP_EOL;

                        // Change the value of a private property of the object
                        $this->changeableVar = 2;
                };
        }

        /**
         * Method that displays a private property
         */
        public function showChangeableVar() {
                echo 'Private property in method: ' . $this->changeableVar.PHP_EOL;
        }

}

// Memory befor the objects is created
echo "Memory: " . memory_get_usage() . PHP_EOL; // Memory: 229896

// Create object
$testObj = new testClass();

// Create closure
$closure = $testObj->closure();

// Execute closure
$closure(); // Private property: 1

// Displaying the current value of the private property
$testObj->showChangeableVar(); // Private property in method: 2

// Memory befor object will be unset
echo "Memory: ". memory_get_usage() . PHP_EOL; // Memory: 266240

// Unset the object
unset($testObj);

// Memory after the object was distroyed, there is no big difference in memory
echo "Memory: ". memory_get_usage() . PHP_EOL; // Memory: 266152

// Run closure after the object in which it was created was unset
echo $closure(); // Private property: 2

// Unset closure and with it the object environment
unset($closure);

// Memotry after the las reference to the object (closure) is unset
echo "Memory: " . memory_get_usage() . PHP_EOL; // Memory: 230416

Callable type hinting

Another new feature introduced in PHP 5.4 regarding closures is the new “type hint”: “callable”. Actually callable is referring to any anonymous function, and even to a new way of calling a method of an object:

<?php

// A function that uses type hinting
function typeHinting(callable $a) {
     echo $a() . PHP_EOL;
}

// A closure
$closure = function () {
     return __FUNCTION__;
};

// Call the type hinting function with the closure
typeHinting($closure); // {closure}

class testClass {
     public function testMethod() {
          return __METHOD__;
     }
}

// A mock object
$testObj = new testClass();

// The new way of calling object methods
$objCallable = array($testObj, 'testMethod');

// Call type hinting function with the new method calling way
typeHinting($objCallable); // testClass::testMethod

I believe that only now we can really say that PHP supports closures, the right way!

Written by Claudiu Persoiu

11 February 2012 at 5:10 PM

Posted in PHP

Tagged with , , , ,

PHP 5.4 Alpha 1 is here!

without comments

Three days ago, that is on 28-06-2011 the PHP 5.4 alfa 1 version was announced on ww.php.net!

Basically in this release are the things that were made for PHP 6 and did not make it in PHP 5.3, next to some other new features.

Some of the most interesting new features are:

Traits

A new OOP feature. Basically for horizontal code reuse, that is inheriting of methods instead of extending classes.

trait Inharitable {
    public function test() {
        echo 'Class: ' . __CLASS__ . ' Method: ' . __METHOD__ . PHP_EOL;
    }
}

class A {
    use Inharitable;
}

class B {
    use Inharitable;
}

$a = new A();
$a->test(); //Class: Inharitable Method: Inharitable::test

$b = new B();
$b->test(); //Class: Inharitable Method: Inharitable::test

Traits in PHP 5.4 are the new namespaces of PHP 5.3, that is the most interesting feature in PHP 5.4.

Scalar type hinting

Up to PHP 5.3 there was type hinting only for classes, interfaces and arrays. With PHP 5.4 type hinting can be used for scalar data types like: int, string, float, book and resource.

function test(string $var) {
  echo $var;
}

$a = 'aa';
test($a);

Unfortunately on this alpha version on my computer I get: Catchable fatal error: Argument 1 passed to test() must be an instance of string, string given, called in .. on line 58 and defined in … on line 52

What can I say… it is still an alpha…

Closures

Yes, I know, there are closures in PHP 5.3 too, but there are not the same. In PHP 5.3 if you wanted a closure you had to use the keyword use and then specify the variables that the lambda functions will have access to.

In PHP 5.4 it’s beginning to look more like JavaScript, in a good way:

class closureTest {

    private $a;

    function test() {
        $this->a = 'object var';
        return function () {
            echo $this->a;
        };
    }
}

$a = new closureTest();
$b = $a->test();
$b(); // object var
unset($a);
$b(); // object var

Closure in the right way, with a lambda function the way it should be! Just like lambda functions existed even before PHP 5.3, but only after the new syntax they’ve become popular, now there was closures time.

This are some of the things that I find most interesting, but there are only a part of the new features that PHP 5.4 brings!

It’s likely that before the end of this year the final version will be ready.

I’m curious if with the final version of PHP 5.4 a new certification will come out, taking in consideration that the changes are not major.

Written by Claudiu Persoiu

1 July 2011 at 8:27 AM

Closures and lambda functions in PHP vs. JavaScript

with 2 comments

JavaScript and PHP support both lambda functions and closures. But the terms are poorly understood in both programming languages ​​and are often confused with each other.

Lambda functions

Also called anonymous functions. They refer to functions that can be called without being bound to an identifier. One of their purposes is to be passed as arguments. The Lambda name was introduced by Alonzo Church, inventor of lambda calculus in 1936. In lambda calculus all functions are anonymous.

JavaScript

In JavaScript lambdas are part of the standard set and there are the preferred method of defining functions.

For instance:

var add = function (a, b) {
     return a + b;
}
alert(add(1, 2)); // 3

Lambda functions are used almost in any context when it comes to JavaScript, like:

window.onload = function (e) {
     alert('The page has loaded!');
}

PHP

In PHP, lambda functions were introduced in version 4.0.1 using create_function. In version 5.3+ a similar syntax to JavaScript was added, a much more readable and elegant way of defining a function.

This means that in PHP there are two ways of creating a lambda function:

// PHP 4.0.1+
$add = create_function('$a, $b', 'return $a + $b;');

// vs.

// PHP 5.3+
$add = function ($a, $b) {
     return $a + $b;
};

echo $a(1,2); // 3

Lambda functions can be used as parameter for other functions, such as usort:

$array = array(4, 3, 5, 1, 2);
usort($array, function ($a, $b) {
     if ($a == $b) {
          return 0;
     }
     return ($a < $b) ? -1 : 1;
});

Even more, PHP 5.3+ allows calling an object as a anonymous function:

class test {
     function __invoke($a) {
          echo $a;
     }
}
$a = new test();
$a('test'); // 'test'

Closures

The closure is really the misunderstood concept of the two. In general confusion appears because closures may involve lambda functions. A closure refers to the ability of a function/object to access the scope in which it was created even if the parent function has ended it’s execution and returned. In other words, the function/object returned by a closure is running in the scope in which it was defined.

In JavaScript the notion of closure is part of the standard arsenal, because the language is not based on the traditional object model, but rather on prototypes and functions. But JavaScript has some traditional object model parts, like the fact that you can use “new” to construct an object based on a function that plays the role of a class. In PHP closures are more of an new way to approach problems, because PHP is part of the traditional object model family.

JavaScript

In JavaScript the notion of closure is widely used, it’s so popular because JavaScript is not a traditional object orientated language, but rather a functional one, based on prototype inheritance.

JavaScript doesn’t have Public, Private and Protected, but rather only Public and Private and objects an inherit from each other, without using classes.

Another issue is the scope, because the global scope is used by default. This issues can be fixed in an elegant fashion using closures:

var closure = function () {
     var sum = 0;
     return {
          add: function (nr) {
               sum += nr;
          },
          getSum: function () {
               return sum;
          }
     }
}();

closure.add(1);
closure.add(2);
console.log(closure.getSum());

In the example above, sum is a private property and in theory can only be accessed and modified by the closure function. The interesting part is that the parentheses from the end of the function definition, signify that this function will be immediately  executed and therefore will return the result which is an object. At this point the original function will only exist for serving the return object, encapsulating therefor the private variable.

Although the function has finished execution, through this closure the returned object can still access the variables defined in the function scope, because that was the environment in which it was created.

This becomes even more interesting when a function returns another function:

var counter = function () {
    var counter = 0;
    console.log('in closure');
    return function () {
        console.log('in the anonymous function');
        return ++counter;
    };
};
var counter1 = counter();

console.log(counter1()); // 1

var counter2 = counter();
console.log(counter2()); // 1
console.log(counter1()); // 2

The output will be:

in closure
in the anonymous function
1
in closure
in the anonymous function
1
in the anonymous function
2

What actually happens is that the first function is executed and returns an anonymous function that can still access the environment in which it was created. In my opinion this is where the confusion between closures and lambda functions comes from, because a function returns another function.

The difference between examples is that in the first one the closure function executes immediately, and in the second example when counter is executed it’s returning a result that is actually a function definition, which in turn can be executed. Of course the second example can be modified to act just like in the first example using parenthesis.

PHP

As I said above, the notion of closure in PHP is not as important as in JavaScript.

Considering that lambda functions are available in the language since version 4, closures only appeared with PHP 5.3+.

Because of the block scope nature of PHP, there is a better encapsulation but there is a lot less flexibility compared to JavaScript. Basically in PHP you must specify using the use instruction what will the anonymous function be able to access from the closure scope.

function closure () {
     $c = 0;
     return function ($a) use (&$c) {
          $c += $a;
          echo $a . ', ' . $c . PHP_EOL;
     };
}

$closure = closure();

$closure(1);
$closure(2);

Unlike JavaScript, in PHP closures can not return objects, or rather the object can not be bound to the scope in which it was created, unless you send the variables as a reference to the constructor, in which case is not very elegant and I can’t imagine a scenario that would absolutely need closure for this.

Like in the JavaScript examples, instead of parentheses “()” at the end of the function, in PHP to run a function immediately after defining it call_user_func() or call_user_func_array() can be used:

$closure = call_user_func(function () {
    $c = 0;
    return function ($a) use (&$c) {
        $c += $a;
        echo $a . ', ' . $c . PHP_EOL;

    };
});

$closure(1);
$closure(2);

Written by Claudiu Persoiu

16 April 2011 at 6:02 PM

PHP 5.3 ce aduce nou?

without comments

Pana la versiunea mult asteptata 6, PHP 5.3 este deja la RC 2.

PHP 5.3 vine cu multe lucruri noi, de fapt sunt atat de multe incat putea sa fie cu succes versiunea 6, dar de ce nu este PHP 6? Pentru ca toata lumea se asteapta ca versiunea 6 sa aiba suport Unicode, iar cand o comunitate de programatori asteapta de mai bine de 3 ani asta, nu poti pur si simplu sa le spui ca te-ai gandit sa lasi suportul pentru Unicode pentru versiunea 7.

Namespaces

Printre noutati se afla si namespaces, mi se pare o idee interesanta dar nu fantastica, initial acestea nu erau pe lista de prioritati pentru ca se considera ca problema lor se poate rezolva relativ simplu folosind prefixuri si clase.

Un exemplu de namespace:

<?php
// clasa.php

// definirea namespace-ului, in cazul asta trebuie sa fie prima instructiune din fisier
namespace teste;

// o clasa cu un conscturctor
class clasaTest {
   function __construct() {
      echo "in constrcutor";
   }
}

// o functie
function funcTest() {
   echo "in functie";
}

// o constanta
const CONSTANTA = 'global';
?>

Acelasi fisier se mai poate defini intr-un anumit namespace si in felul urmator:

<?php
// clasa.php

// definirea namespace-ului
namespace teste {

   // o clasa cu un conscturctor
   class clasaTest {
     function __construct() {
        echo "in constrcutor";
     }
   }

   // o functie
   function funcTest() {
      echo "in functie";
   }

   // o constanta
   const CONSTANTA = 'global';

}
?>

Fisierul in care fac testele:

<?php

// includem fisierul de mai sus
require('clasa.php');

$obj = new clasaTest(); // Fatal Error:clasa 'clasaTest' not found in ...

$obj2 = new teste\clasaTest(); // afisaza "in constructor"

// aparent suprascriem constanta
const CONSTANTA = 'local';

echo CONSTANTA; // afisaza "local"

echo teste\CONSTANTA; // afisza "global"

teste\funcTest(); // afisaza "in functie"

?>

iar daca vrem sa nu mai folosim operatorul “\” si numele namespace-ului:

<?php
// trebuie sa fie prima insctructiune
namespace teste;

// includem fisierul de mai sus
require('clasa.php');

$obj = new clasaTest(); // afisaza "in constructor";

// suprascriem constanta
const CONSTANTA = 'local'; // Notice: Constant teste\CONSTANTA already defined in...

echo CONSTANTA; // afisaza global

?>

Si acestea sunt functiile de baza, folosindu-le pe acestea o sa ajute portabilitatea, si scalabilitatea. Acum numele de clase si functii nu mai trebuie sa fie unice, trebuie pur si simplu sa fie in namespace-uri diferite.

Functile lambda si “closures”

Cele mai interesante facilitati mi se par functile lambda si “closures”.

Suna cunoscut? Poate pentru ca sunt foarte folosite in JavaScript:

<script language="javascript">
closure = function(text) {
   alert(text);
}

closure("hello");
</script>

Iar acum in php este posibil:

<?php
$closure = function ($text) {
   return $text;
};

echo $closure("hello");
?>

Tot la functii lambda si “closures” a mai fost introdus si “use”, care permite folosirea unor variabile din exterior:

<?php
$x = 'Claudiu';
$closure = function ($text) use ($x) {
   return $text.' '.$x;
};

echo $closure("hello"); // afisaza "hello Claudiu"
?>

Iar daca in exemplul de mai sus vrem sa modificam variabilele care sunt parametri la “use” nu trebuie decat sa le trimitem prin referinta:

<?php
$x = 'Claudiu';
$closure = function ($text) use (&$x) {
   $x = 'utilizator';
   return $text;
};

echo $closure("hello"); // afisaza "hello"

echo $x; // afisaza "utilizator"
?>

Iar ca sa luam un exemplu concret unde pot fi utile, sa zicem functia “usort“:

<?php
function cmp($a, $b)
{
    if ($a == $b) return 0;
    return ($a < $b) ? -1 : 1;
}

$a = array(3, 2, 5, 6, 1);

usort($a, "cmp");

// este echivalent cu:

$a = array(3, 2, 5, 6, 1);

usort($a, function ($a, $b){
    if ($a == $b) return 0;
    return ($a < $b) ? -1 : 1;
});
?>

Dragut, nu? Cred ca asa se vede si mult mai clar ce se intampla in functie si la ce foloseste aceasta.

De asemenea obiectele se pot comporta ca niste closures folosind noua “metoda magica” __invoke():

<?php 

class testCl {
   function __invoke() {
      return "metoda de closure";
   }
}

$obj = new testCl(); // instantiem clasa
echo $obj(); // o apelam ca pe un closure si afisaza "metoda de closure"

?>

NOWDOC

NOWDOC este similar cu HEREDOC doar ca nu interpreteaza variabilele si caracterele speciale. Cu alte cuvinte HEREDOC era echivalentul ghilimelelor duble, NOWDOC este echivalentul ghilimelelor simple:

<?php

$var = "5";

// ghilimele duble
echo "Valoarea este: $var <br>"; // "Valoarea este 5"

// ghilimele simple
echo 'Valoarea este: $var <br>'; // "Valoarea este $var"

// HEREDOC
echo <<<HEREDOC
Valoarea este: $var <br>
HEREDOC;
// "Valoarea este 5"

// NOWDOC
echo <<<'NOWDOC'
Valoarea este: $var <br>
NOWDOC;
// "Valoarea este $var"

?>

Operatorul “?”

Acest operator a fost putin “inbunatatit”:

<?php
// inainte
echo $_GET['ceva']?$_GET['ceva']:false;

// acum
echo $_GET['ceva']?:false;

?>

Cu alte cuvinte acum conditia poate fi folosita ca valoare pentru adevarat.

goto

Sincer… nuprea vad de ce era nevoie de asa ceva, dar poate nu e chiar asa rau. Si un mic exemplu:

<?php

$x = 1;

label1:
echo "la label1 $x <br>";
$x++;

if($x>3) goto label2;
goto label1;

label2:
echo "la label2";

// va afisa:
// la label1 1
// la label1 2
// la label1 3
// la label2
?>

Arata mai mult a Basic decat a PHP dar chiar functioneaza.

Mai sunt si alte noutati, am incercat sa le enumar doar pe cele care mi se pare mie mai interesante.

Din pacate toate aceste lucruri nu vor ajunge sa fie folosite cu adevarat pe scara larga decat poate peste 2-3 ani, sau chiar mai mult. Poate nu este PHP 6 dar eu cred ca toate schimbarile vor fi mai degraba asociate cu PHP 6 decat cu PHP 5, nu cred ca vrea nimeni sa riste o intreaga aplicatie care foloseste namespace-uri sau closures pentru ca nu este versiunea “noua” de PHP 5.

Written by Claudiu Persoiu

10 May 2009 at 5:42 PM

Posted in PHP

Tagged with , , , , ,