7 kyu

PHP Functions - Anonymous Functions (aka Closures)

442 of 443donaldsebleung
Description
Loading description...
Fundamentals
Tutorials
View
AllIssues1Questions1SuggestionsShow Resolved
  • Please sign in or sign up to leave a comment.
  • 4ejigyh Avatar

    This comment has been hidden.

  • 4ejigyh Avatar

    what is this error for?: Parse error: syntax error, unexpected 'class' (T_CLASS) in /home/codewarrior/run.php on line 8 my code: $hello_world = function() {return 'Hello World';}; $person_description = function ($name, $age, $occupation) { return "$name is $age years old and currently works as a $occupation"; }

  • Sejiko Avatar

    i think named func. are cleaner... and i dont get the advantage of the unnamed functions. you have a little bit more code but your code is clean.

    • smolen Avatar

      Its true,writing unnamed function is slighty faster but code is a little messy after. If function is really simple like multiply example its good place for unnamed functions,when you know that you will not use it again. In JS alot of people use unnamed functions in sorting arrays too.

      Its good to have more options how to pass/write functions :)

    • Sejiko Avatar

      i agree with your opinion ;)