我有一個奇怪的錯誤,我沒有成功地能夠谷歌結果或找到一個解釋,我可以瞭解stackOverflow。我的代碼在我的本地服務器上正常工作,按照我的預期執行,但是當我上載它時,它會返回以下錯誤'*語法錯誤,意外'['in /home/maxster/max-o-matic.com/_inc/第59行的'functions.php'。PHP語法錯誤,意外的'['發生在主機服務器上,不是本地服務器......奇怪?
下面是線#59:
$aaPlaceholderIndex = array_keys($aaPlaceholder)[$row*4+$image]; //if associative array
這裏是全功能:
function PrintFolio($aaPlaceholder)
{
//print out X number rows, four items at time
$itemsCount = sizeof($aaPlaceholder);//get size of array
$height = (int)ceil(sizeof($aaPlaceholder)/4);//get size of array divided by 4
//loop through array of X items, for each group of 4 print as a row
for($row = 0; $row < $height; $row++) //looping through the rows
{
echo '<div class="row flush">'; //open div
for($image = 0; $image < 4; $image++) //each row is composed of 4 images
{
//$aaPlaceholderIndex = $row*4+$image; //if indexed array
$aaPlaceholderIndex = array_keys($aaPlaceholder)[$row*4+$image]; //if associative array
if($aaPlaceholderIndex <= $itemsCount) {
printf(TEMPLATE_PORTFOLIO, $aaPlaceholderIndex, $aaPlaceholder[$aaPlaceholderIndex]);
//$template = '<div class="3u"><a href="_img/fulls/%1$s" class="image full"><img src="_img/thumbs/%1$s" alt="" title="%2$s" /></a></div>';
}
}
echo '</div>'; //end div group of 4
}//end loop
}//end function
我抓我的頭就這一個了很多,因爲它似乎是一個功能是好的,它的格式似乎對我來說很合適,而且一切都在一個合理的位置上,並且流暢。我相信這可能會更好,但對我來說,這是非常好的考慮到我的技能水平 - 我是一個新手。任何想法是什麼導致方形支架的問題?
所以這是我的主機環境運行早期版本的PHP。哇,你通過詢問學到的東西。謝謝我將探討這一點,並着眼於升級我的服務器。謝謝。 – Chezshire