我正在做一些PHP编码。在这部分代码中,我收到错误意外{
:
function image_filenames($dir){
$handle = @opendir($dir) or die("I cannot open the directory '<b>$dir</b>' for reading.");
$images = array();
while (false !== ($file = readdir($handle))){
if (eregi('\.(jpg|gif|png)$', $file){
$images[] = $file;
}
}
closedir($handle);
return $images;
}
错误是专门针对{
行中的if (eregi('\.(jpg|gif|png)$', $file){
提供的
如果我评论此功能,页面加载完全正常。
我缺少什么?
答案 0 :(得分:2)
你错过了一次&#39;)&#39;
Count 3
Books
Book
Title Book 1
Author Author 1
Book
Title Book 2
Author Author 2
Book
Title Book 3
Author Author 3
Details
Errors 0
答案 1 :(得分:1)
一个简单的拼写错误:
您的代码中存在解析错误。
观察缺失的支具:
更改
if (eregi('\.(jpg|gif|png)$', $file){
要:
if (eregi('\.(jpg|gif|png)$', $file)){