无法逃脱 [英] Can't Escape

查看:65
本文介绍了无法逃脱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在尝试做一些简单的事情并从php

手册中获取一个片段来读取目录中的文件。该片段回复了一个很好的

文件列表。

<?php

//打开图像目录

$ dir = opendir(" images");

//列出images目录中的文件

while(($ file = readdir($ dir))!== false)

{

echo" filename:" 。 $ file。 "< br />";

}

closedir($ dir);

?>


所以我的PHP技能非常有限,我试图在图像标签中连接

$文件变量。我似乎无法以正确的方式逃避这种方式。我已经完成了一些切割,粘贴和评论试图

计算出来。 (继续笑。:)


<?php

//不工作 - 显示小蓝色问号框

echo"< img src = \" /DSC01351.jpg \">" ;;

//作品

echo"< ; br>" ;;

//打开图像目录

$ dir = opendir(" images");

//列出文件在图像目录中

while(($ file = readdir($ dir))!== false)

{

//以下作品 - - 显示文件名,如DSC01351.jpg

echo" filename:" 。 $ file;

// NOT - 显示小蓝色问号框

echo"< img src =" 。 $ file。 ">";

// NOT - 显示小蓝色问号框

echo"< img src = \"。$ file。 \">" ;;


}

closedir($ dir);

?>


对于那么简单的事情感到非常沮丧。我试过了很多方法来逃避img标签中的引号但是不能让它起作用。

留下了几个例子......


非常感谢任何帮助。


TIA!

解决方案

dir = opendir(" images");

//列出图片目录中的文件

while((


file = readdir(


dir))!== false)

{

echo" filename: "

Hi all,

I''m trying to do something simple and grabbed a snippet from the php
manual for reading files in a directory. The snippet echos out a nice
list of files.
<?php
//Open images directory
$dir = opendir("images");
//List files in images directory
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir);
?>

So with my very limited PHP skillset I am trying to concatente the
$file variable in an image tag. I can''t seem to escape this the right
way. I''ve done some cutting and pasting and commenting trying to
figure this out. (keep the laughing down. :)

<?php
//NOT WORKING - shows the little blue question mark box
echo "<img src = \"/DSC01351.jpg\">";
//Works
echo "<br>";
//Open images directory
$dir = opendir("images");
//List files in images directory
while (($file = readdir($dir)) !== false)
{
// Below Works---Shows the filename like DSC01351.jpg
echo "filename: " . $file;
//NOT - shows the little blue question mark box
echo "<img src=" . $file . ">";
//NOT - shows the little blue question mark box
echo "<img src=\".$file.\">";

}
closedir($dir);
?>

Just amazingly frustrated with something that is so simple. I''v tried a
lot of ways to escape the quotes in the img tag but can''t mahe it work.
left a couple of example...

Any help would be greatly appreciated.

TIA!

解决方案

dir = opendir("images");
//List files in images directory
while ((


file = readdir(


dir)) !== false)
{
echo "filename: " .


这篇关于无法逃脱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆