1

このエラーが発生します:

解析エラー:構文エラー、予期しないT_FUNCTION

このコードで:

<?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 ') : '';
    }
?>

この行で:

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

PHPバージョン:5.2.17

ローカルホストで動作します。最新のUniServerを使用しています。しかし、これをホストに移動すると、エラーが発生します。

何か助けはありますか?:)

編集:これは、修正が必要かどうかわからない他の人です。

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']);
}

2番

    $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 ') : ', ') : '';
    }

これら2つにも修正が必要なものはありますか?

4

1 に答える 1

6

PHP 5.3 より前ではクロージャーを使用できません。tofunctionの 2 番目の引数でそれを変更する必要があります。試す:array_walkcreate_function

array_walk($uniqueFtypes, create_function('&$ftype, $key;',
   '$ftype = $ftype["fileExt"];'));
于 2012-09-18T00:27:59.857 に答える