Php照片显示
目前,我已使用php将我目录中某个文件夹中的图像显示在屏幕上,如下所示:Php照片显示,php,gallery,photo,Php,Gallery,Photo,目前,我已使用php将我目录中某个文件夹中的图像显示在屏幕上,如下所示: $file_display = array('jpg', 'jpeg', 'png', 'gif'); $dir = 'images'; if (file_exists($dir) == false) { echo 'Doesnt exist'; } else { $dir_contents = scandir($dir); foreach ($dir_contents as $file)
$file_display = array('jpg', 'jpeg', 'png', 'gif');
$dir = 'images';
if (file_exists($dir) == false)
{
echo 'Doesnt exist';
}
else
{
$dir_contents = scandir($dir);
foreach ($dir_contents as $file)
{
$file_type = strtolower (end (explode('.', $file)));
if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true)
{
echo '<img src="', $dir, '/', $file, '" alt="', $file,'" />';
}
}
}
$file_display=array('jpg','jpeg','png','gif');
$dir='images';
如果(文件_存在($dir)==false)
{
回声“不存在”;
}
其他的
{
$dir\u contents=scandir($dir);
foreach($dir\u内容为$file)
{
$file_type=strtolower(end(explode('.',$file));
如果($file!='.&&$file!='..'&&in_数组($file\u type,$file\u display)==true)
{
回声';
}
}
}
我有一个600像素的屏幕大小设置宽度。我现在正试图在屏幕下方的4列中显示这些图像,并要求所有图像的大小都相同
有人知道怎么做吗?试试这个:
echo '<img src="'.$dir.'/'.$file.'" alt="'.$file.'" width="600px" />';
echo';
Thank:)如果我想单击其中一个图像在弹出窗口中显示完整图像,我将如何实现这一点?