1
class test
{
    public $do;
    function __construct($data="")
    {
        $this->parse($data);
    }
    private function parse($data)
    {
        // Decoding the functions
        $decoded_data = json_decode($data,true); 
        array_walk_recursive($decoded_data,function(&$function) {
            $first_line = strtok($function, "\n");
            preg_match("/\/\*#(.*?)\#*\//",$first_line,$matches);
            $function = create_function($matches[1],$function);
        });
        $this->do = $decoded_data;  
    }
}

Parse error: syntax error, unexpected T_FUNCTION

The error is in:

array_walk_recursive($decoded_data,function(&$function)

3
  • 1
    Can you ensure that the code above is pasted exactly as it exists in your file? Start the copy/paste from the VERY first line: <?php... Commented Jul 11, 2012 at 4:29
  • Just as well to call out the line... thanks! Commented Jul 11, 2012 at 4:30
  • you can usually get very relevant results by googling the php error messages, and this is true here. Commented Jul 11, 2012 at 4:31

1 Answer 1

11

Check your PHP version, anonymous functions are only supported on 5.3+

Sign up to request clarification or add additional context in comments.

2 Comments

i think array_walk_recursive supported in PHP5
I had a similar problem, changed PHP version to 5.4. Means mysql will be deprecated, so you have to use mysqli or PDO

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.