loading...

re: How to write a different PHP? VIEW POST

FULL DISCUSSION
 

It would have been much more useful if the arrow syntax could be used for multiline function.

I actually like that it closes over the value of the enclosing scope. It would have been much more useful when creating an anonymous function that uses data from the enclosing scope.

<?php
function create($name,$age) {
    $this->em->transactional(fn() {
        $person = new Person($name,$age);
        $this->em->persist($person);
        $this->em->flush();
    });
}
 

Yes, it would have been awesome. Maybe in the later version, they will add such a feature.

Code of Conduct Report abuse