Double quotes question
| From: | Clay Culver | Date: | Mon, 03 Jun 2002 13:48:46 +0000 |
| Subject: | Double quotes question | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-14051@lists.php.net to get a copy of this message | ||
Hi,
I have a script that lists the files in a directory, and
create links accordingly but if the files contain spaces then the link
won't come out correctly. I am fairly new to PHP and have no real idea
on how I can get it to make links show as <a href="link"></a> currently
it will put links like <a href=link></a> which is causing the problem.
Below is the script.
[script]
<?
function directory($result) {
$handle=opendir(".");
while ($file = readdir($handle)) {
if ($file == "." || $file == "..") { } else { print "<a
href=$file>$file</a><br />\n"; }
}
closedir($handle);
return $result;
}
?>
[/script]
I did try going else { print "<a href="$file">$file</a><br
/>\n"; } but all I get is PHP errors doing this until the double quote
is removed, any help in this would be great.
Clay