我無法弄清楚什麼是存儲在數組中......任何人都可以請解釋它。請以簡單的方式解釋它。謝謝大家 我已經從網絡和完整的代碼試了一下這裏這段代碼在php中做什麼目錄
<?php
$dhandle = opendir('.');
$files = array();
if ($dhandle) {
while (false !== ($fname = readdir($dhandle))) {
if (($fname != '.') && ($fname != '..') && ($fname != basename($_SERVER['PHP_SELF']))) {
// this if condition is confusing me
$files[] = (is_dir("./$fname")) ? "(Dir) {$fname}" : $fname;
// and the above line too
}
}
closedir($dhandle);
}
echo "<select name=\"file\">\n";
foreach($files as $fname)
{
echo "<option>{$fname}</option>\n";
}
echo "</select>\n";
?>
這裏是我不明白
$files[] = (is_dir("./$fname")) ? "(Dir) {$fname}" : $fname;
'?'是三元運算符。 http://php.net/ternary –