wordpress插件错误在服务器上

i wrote a plugin and it successfully works on my localhost.But when i install it my server and want to activate it fails.

Plugin could not be activated because it triggered a fatal error.

Parse error: syntax error, unexpected T_FUNCTION in /home/ozcanco/public_html/said/wp-content/plugins/Archive/my-plugin.php on line 22

But when i run this plugin on my local it successfully works.By the way my wordpress versions are same,on local and server.How come this happen?

The line 22 is like that:

   add_action('loop_start', function($query) use ($allContent){     

That inline function you have is called an anonymous function, or a closure. Closures only became part of PHP in version 5.3, so if your servier is running 5.2 or lower it will not support them.

http://php.net/manual/en/functions.anonymous.php

If upgrading the server is not an option, then as krike suggested in the comment, you could use a callback function instead:

add_action('loop_start', 'loopStartCallback');

function loopStartCallback($query) {
    global $allContent;
    // body of the closure goes here
}