1

I'm getting this error:

Parse error: syntax error, unexpected T_FUNCTION

at this code:

<?php
    $uniqueFtypes = $ftypes = $converter->GetConvertedFileTypes();
    array_walk(
        $uniqueFtypes, 
        function(&$ftype, $key) {
            $ftype = $ftype['fileExt'];
        }
    );
    $uniqueFtypes = array_values(array_unique($uniqueFtypes));
    foreach ($uniqueFtypes as $key => $uftype)
    {
        echo $uftype;
        echo ($uftype != end($uniqueFtypes)) ? (($key != count($uniqueFtypes)-2) ? ', ' : ', or ') : '';
    }
?>

At this line:

array_walk(
    $uniqueFtypes, 
    function(&$ftype, $key) {
        $ftype = $ftype['fileExt'];
    }
);

PHP Version: 5.2.17

It works on localhost, I'm using latest UniServer. But when I moved this to my host, it gives that error.

Any help? :)

Edit: Here is others im not sure does it need fixing.

ini_set('max_execution_time',0);
ini_set('display_errors',0);

// Instantiate converter class
include 'VideoConverter.class.php';
$converter = new VideoConverter();

// On download of converted file
if (isset($_GET['output']))
{
    $converter->DownloadConvertedFile($_GET['output']);
}

Second

    $vidHosts = array_values($converter->GetVideoHosts());
    foreach ($vidHosts as $key => $host)
    {
        echo $host['name'];
        echo ($host != end($vidHosts)) ? (($key == count($vidHosts)-2) ? ((count($vidHosts) > 2) ? ', and ' : ' and ') : ', ') : '';
    }

Is there something that needs fixing on these 2 also?

1
  • Have you confirmed PHP version same on localhost and remote host? Commented Sep 18, 2012 at 5:54

1 Answer 1

6

You can't use closures before php 5.3. You need to change that function in the second argument of array_walk to create_function. Try:

array_walk($uniqueFtypes, create_function('&$ftype, $key;',
   '$ftype = $ftype["fileExt"];'));
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for reply, after changing that line, it shows only white on my page so I think there is other code that needs to be fixed. I edited first post to show other codes that might need to be fixed, could you tell if its so?
@Lanibox it shouldn't only show white; turn errors on and tell me what they are so I can help you. However, I think you should accept this and create a separate question if you have multiple, disparate issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.