![](/img/trans.png)
[英]PHP version 4 :: Parse error: syntax error, unexpected '=', expecting ')'
[英]Parse error: syntax error, unexpected '[', expecting ')', possibly PHP version issue
我的代碼給出了錯誤。 我知道現在它與php版本有關。 但是我應該更改我的代碼以使其正常工作嗎?
$json = file_get_contents(
'https://api.instagram.com/v1/users/'. $user_id .'/media/recent/?client_id=' . $client_id . '&count=' . $count);
$decode = json_decode($json, true);
$output = '';
$func = function($post['tags']){
$i=0;
while(!empty($post['tags'])){
return $post['tags'][$i]." ";
$i++;
}
};
foreach ($decode['data'] as $post) {
$output .= $modx->getChunk($tpl,
array(
'link' => $post['link']
,'image' => $post['images']['standard_resolution']['url']
,'likes' => $post['likes']['count']
,'hashtags' => $func
)
);
}
return $output;
謝謝
錯誤是您將$post['tags']
傳遞給函數聲明。 你可以改變
$func = function($post['tags'])
...
至
$func = function($tags) {
$i=0;
while(!empty($tags)){
return $tags[$i]." ";
$i++;
}
}
然后稱其為
$func($post['tags'])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.