Discussion: Can't Escape
Afficher un message
Vieux 11/09/2007, 23h41   #1
Confused but working on it
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Can't Escape

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 would be greatly appreciated.

TIA!

  Réponse avec citation
 
Page generated in 0,08285 seconds with 9 queries