php Object of class Closure could not be converted to string -


i'm creating search-function php-based file manager. i'm getting error: 'catchable fatal error: object of class closure not converted string' on following line:

if ($data->input_ext) {     $data_ext = ($begun ? ($data->input_logic ? ' or ' : ' , ') :     function ()     {         $begun = true;         return "";     }) . 'ext = "' . $data->input_ext . '"';     $data_string.= $data_ext; } 

that's part of builds sql query. $begun_files determines whether or not put 'or' or 'and' @ beginning based on whether or not user input name or comes before match. have feeling i'm not allowed include anonymous functions in ternary expressions should instead?

thanks!

you can't use anonymous functions inline flow control; use regular if statement , don't shun writing things on multiple lines:

if ($data->input_size) {   if ($begun_files) {       $str .= $data->input_logic ? ' or ' : ' , ';       $begun_files = true;   }   $str .= sprintf('size %s "%f"',       $data->input_size_op ? '<=' : '>=',       $data->input_size * pow(1024,$data->input_size_unit)   ); } 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -