【发布时间】:2014-10-27 05:20:30
【问题描述】:
我正在尝试显示文件夹中的图像。当我运行我的脚本时,出现以下错误 -
"Only variables should be passed by reference in C:\wamp\www\salon\mainS\image_delete.php on line 72"
代码:
<?php
$dir = 'uploads/';
$display = array('jpg', 'jpeg', 'png', 'gif');
if (file_exists($dir) == false) {
echo 'Directory \''. $dir. '\' not found!';
} else {
$dir_contents = scandir($dir);
foreach ($dir_contents as $file) {
$type = strtolower(end(explode('.', $file)));
if ($file !== '.' && $file !== '..' && in_array($type, $display) == true)
{
echo'<div style="width:1170px;" >'.
'<div style="float:left; margin-right:5px;" >'.'<img style="width:200px; height:200px;"src="'. $dir. '/'. $file. '" alt="'. $file.'"/>'.'</div>'
.'</div>';
}
}
}
?>
我的第 72 行是
$type = strtolower(end(explode('.', $file)));
【问题讨论】:
-
转储
$file看看你得到了什么。 -
您的代码对我来说运行良好...如果有任何其他问题,请检查 image_delete.php 文件