Re: probelem with script
| From: | Ilker Cetinkaya | Date: | Wed, 05 Jun 2002 14:05:46 +0000 |
| Subject: | Re: probelem with script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-100689@lists.php.net to get a copy of this message | ||
you're casting is wrong,
instead of
$s = int filesize($f);
do
$s = (int)filesize($f);
btw - next time an error message would help your helper :-)
hth
ilker
"_michael" <ace@ringway77.freeserve.co.uk> wrote in message
news:EIEALMAHCAMGPIOAKJHMMEEPECAA.ace@ringway77.freeserve.co.uk...
> /*
> what i'm trying to do is read the files and folders in the directory and
> output them into an xml document - when i try to find the size of the file
i
> get an error - can someone please tell me why this is
>
> thanks
>
> mike
> */
>
> // SCRIPT [dir.php]
> <?
> function folder2XML(){
> $fp = opendir('.'); // make $fp hold
the
> current directory
> while (false !== ($file = readdir($fp))) { // for each file or
> folder in the directory...
> if ($file != "." && $file != "..") { // if
> it's not the
> current folder or the parent folder...
> if (is_dir($file)) { // if it's a
> folder...
> echo "<folder name='$file'>"; // open the folder
> tag
and
> put the folder name in it
> chdir($file); // change to that
> directory
> folder2XML(); // make our
recursive
> call to display this directory too.
> chdir("../"); // change back to
> previous directory
> echo "</folder>"; // close the folder
> tag
> } else { // if it's a
file...
> // the error is bieng caused here
> $size = int filesize($file)
> echo "<file name='$file' size='$size' />";
> // if you comment out the above 2 lines and include the below instead it
> works
> // echo "<file name='$file' />";
> }
> }
> }
> closedir($fp); // close the open
> directory
> }
> echo("<?xml version='1.0' ?>");
>
> ?><folder name='/'><? // Open the root
> element's tag (it's the root folder, of course)
> folder2XML(); // Display the
folder
> as XML (and all sub folders!)
> ?></folder><? // close the root element
> ?>
> // END
>