Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are anonymous functions allowed?

Both Eclipse and NetBeans throw errors about the use of anonymous functions. The error in NetBeans says The language feature not compatible with PHP version indicated in project settings

The code works but the IDEs doesn't seem to like it.

Should I be worried?

like image 470
Emanuil Rusev Avatar asked Sep 06 '10 13:09

Emanuil Rusev


People also ask

Can functions be anonymous?

An anonymous function is a function that is not stored in a program file, but is associated with a variable whose data type is function_handle . Anonymous functions can accept multiple inputs and return one output. They can contain only a single executable statement.

Is it valid to pass an anonymous function?

Anonymous functions can be used as an argument to other functions or as an immediately invoked function execution.

Where can you use anonymous functions?

Anonymous functions are often arguments being passed to higher-order functions or used for constructing the result of a higher-order function that needs to return a function. If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function.

When should I use anonymous functions?

The advantage of an anonymous function is that it does not have to be stored in a separate file. This can greatly simplify programs, as often calculations are very simple and the use of anonymous functions reduces the number of code files necessary for a program.


2 Answers

NetBeans: in the project settings, set the PHP version to 5.3

like image 170
tamasd Avatar answered Oct 09 '22 21:10

tamasd


Same for Eclipse. In Project Properties, set PHP Interpreter to 5.3.

Also see

  • http://wiki.eclipse.org/PDT/Installation/Execution_Environment
  • http://www.eclipse.org/pdt/release-notes/pdt2_1.php
like image 39
Gordon Avatar answered Oct 09 '22 22:10

Gordon