[PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Ben Crawford

You also seem to have an extra equals. Your loop should read:

while (false != ($file=readdir($handle))){

It should come up as an error, but I'm not sure.

Ben

Manuel Ritsch wrote:

 Hello There

 I'm new to PHP and trying to code a function that reads all teh files out of
 a directory and printing out a link and the filesize,
 but it seems that the filesize() function doesn't work, here's the code so
 far:

  $handle = opendir ('images');
  echo Files:brbr;
  while (false !== ($file = readdir ($handle))) {
  if($file != .  $file != ..)
  {
  $file_s = filesize($file);
  echo a href=images/$file$file/a Filesize:
 $file_sbr;
  }
  }
  closedir($handle);

 and the output is somethingl ike this:

 Files:
 button_test_04.gif Filesize:
 button_test_03-down.gif Filesize:
 lilextras_01.gif Filesize:
 (and so on)...

 You see, there's no Filesize and I don't know why, please help me

 -- manu


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Martin Towell

that should be okay - it's to make sure that it is exactly equal to (as
opposed to equates to be equal to)

eg (0 === false)  = false
   (0 ==  false)  = true

-Original Message-
From: Ben Crawford [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 2:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Newbie: Question about filesize()


You also seem to have an extra equals. Your loop should read:

while (false != ($file=readdir($handle))){

It should come up as an error, but I'm not sure.

Ben

Manuel Ritsch wrote:

 Hello There

 I'm new to PHP and trying to code a function that reads all teh files out
of
 a directory and printing out a link and the filesize,
 but it seems that the filesize() function doesn't work, here's the code so
 far:

  $handle = opendir ('images');
  echo Files:brbr;
  while (false !== ($file = readdir ($handle))) {
  if($file != .  $file != ..)
  {
  $file_s = filesize($file);
  echo a href=images/$file$file/a
Filesize:
 $file_sbr;
  }
  }
  closedir($handle);

 and the output is somethingl ike this:

 Files:
 button_test_04.gif Filesize:
 button_test_03-down.gif Filesize:
 lilextras_01.gif Filesize:
 (and so on)...

 You see, there's no Filesize and I don't know why, please help me

 -- manu


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Jeff Sheltren

At 10:27 AM 2/6/2002 -0500, Ben Crawford wrote:
You also seem to have an extra equals. Your loop should read:

while (false != ($file=readdir($handle))){

I think you could eliminate the false != in the while condition...

It should be just the same if you write
while (($file = readdir($handle)))

right?

-Jeff




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Lars Torben Wilson

On Wed, 2002-02-06 at 07:27, Ben Crawford wrote:
 You also seem to have an extra equals. Your loop should read:
 
 while (false != ($file=readdir($handle))){
 
 It should come up as an error, but I'm not sure.
 
 Ben

No, that's the 'identical' operator, which returns true when its
operands are both equalivalent and of the same type:

  http://www.php.net/manual/en/language.operators.comparison.php


Cheers,

Torben

-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Lars Torben Wilson

On Wed, 2002-02-06 at 15:33, Jeff Sheltren wrote:
 At 10:27 AM 2/6/2002 -0500, Ben Crawford wrote:
 You also seem to have an extra equals. Your loop should read:
 
 while (false != ($file=readdir($handle))){
 
 I think you could eliminate the false != in the while condition...
 
 It should be just the same if you write
 while (($file = readdir($handle)))
 
 right?
 
 -Jeff

Wrong, actually. If you have any files in that directory which have
names which would evaluate as false in PHP, then your way will fail on
them and you'll get a truncated directory listing. Do 'touch 0' in a 
directory and give it a shot; you'll see what I mean.

However, the original example does the same thing, since it only checks
whether the result of the readdir() evaluates to FALSE, not whether it
actually is a boolean FALSE value. The correct way to do this is:

  while (FALSE !== ($file = readdir($handle))) {
 . . . 
  }

Note the !== instead of !=.


Hope this helps,

Torben

-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Newbie: Question about filesize()

2002-01-31 Thread Jim Winstead

Manuel Ritsch [EMAIL PROTECTED] wrote:
 $file_s = filesize($file);

you want $file_s = filesize(images/$file).

jim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]