E_PARSE syntax error, unexpected T_FUNCTION [duplicate]

This question already has an answer here:

Best all,

I am trying to install EPESI on my server. I am a total newbie with this btw. When I tried to run the install of the software I got this error:

Type: E_PARSE (4) 
Message: syntax error, unexpected T_FUNCTION 
File: ../modules/Utils/Attachment/AttachmentCommon_0.php 
Line=945 
error backtrace: 
[PHP core called function] 
    function called: check_for_fatal()

I traced it back and this piece of code is giving me the headache. I hope this is something easy to solve.

private static function max_upload_size() {
    $normalize = function($size) {
        if (preg_match('/^([d.]+)([KMG])$/i', $size, $match)) {
            $pos = array_search($match[2], array('K', 'M', 'G'));
            if ($pos !== false) {
                $size = $match[1] * pow(1024, $pos + 1);
            }
        }
        return $size;
    };
    $max_upload = $normalize(ini_get('upload_max_filesize'));
    $max_post = (ini_get('post_max_size') == 0) ?2*1024*1024: $normalize(ini_get('post_max_size'));
    $memory_limit = (ini_get('memory_limit') == -1) ?$max_post : $normalize(ini_get('memory_limit'));
    if($memory_limit < $max_post || $memory_limit < $max_upload) return $memory_limit;
    if($max_post < $max_upload) return $max_post;
    $maxFileSize = min($max_upload, $max_post, $memory_limit);
    return $maxFileSize;
}


Source: syntax

Leave a Reply