2016-11-10 65 views
0
<?php 
    $tabel = array(); 
    $teller = 0; 
    $handle = opendir(dirname(realpath(__FILE__)).'/images/bbq2015/'); 
     while($file = readdir($handle)){ 
      if($file !== '.' && $file !== '..'){ 
       $tabel[$teller] = $file; 
       $teller++; 
      } 
     } 

     $n = $tabel.length(); 
     for ($i = 0; $i < $n-1; $i++) 
     for ($j = 0; $j < $n-$i-1; $j++) 
      if ($tabel[$j] > $tabel[$j+1]) 
      { 
       $temp = $tabel[$j]; 
       $tabel[$j] = $tabel[$j+1]; 
       $tabel[$j+1] = $temp; 
      } 
     $teller = 0; 
     while($teller < $n){ 
      echo '<a class="example-image-link" href="images/bbq2015/'.$tabel[$teller].'" data-lightbox="example-set" data-title="BBQ 2015"><img class="halloween2015" src="images/bbq2015/'.$tabel[$teller].'"/></a>'; 
      $teller++; 

     } 
?> 

我意识到这可能不是最好的代码,但我试图。 我很想知道我在哪里发生错误,而不是查找我的代码修复。HTTP错误500,不知道从哪里开始

+1

可能从错误报告开始? –

+3

你可以等待一段时间,有人会来一个长的帖子回答说,请添加一个'$'到'$ n = tabel.length();'并且会得到相当多的赞成票。仍然是错误的:P –

+1

是的,我的猜测在这里$ n = tabel.length(); –

回答

0

变化

$n= $tabel.length(); //there is no length() function in PHP 

$n= count($tabel); 

计数()返回在数组元素的数量。