10 thoughts on “How to create my own function with { } in PHP

  1. user

    The problem with anonymous functions is that you have to write them every time you want to use them. If you write a function once, give it a name. The only real use I see for anonymous functions is to add more parameters to a function with function calls like array_map or array_walk.

  2. user

    You can’t.

    Constructs like for or foreach are part of php syntax.

    If you want to create regular function just use function keyword:

    function some_func($x, $y)
  3. user

    There will be lambda functions – that’s what you want to do – in PHP 6.
    Right now you have to stick with “normal” functions.


Leave a Reply

Your email address will not be published.