我收到此错误:
解析错误:语法错误、意外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']);
}
第二
$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 个也有什么需要修复的吗?
在 php 5.3 之前不能使用闭包。 您需要将array_walk
的第二个参数中的function
更改为create_function
。 尝试:
array_walk($uniqueFtypes, create_function('&$ftype, $key;',
'$ftype = $ftype["fileExt"];'));