Filesize problem.

This is a discussion on Filesize problem. within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I am trying to determine if a file contains information. I thought the easiest way to do this would be ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-05-2004
Lee A. Wentzel
 
Posts: n/a
Default Filesize problem.

I am trying to determine if a file contains information. I thought the
easiest way to do this would be to check the files size. So I wrote the
following code.

<html>
<head>
</head>
<body>
<?php
$file_size = filesize("manager/coupon.inc");
echo "file size=" & $file_size;
include("manager/coupon.inc");
?>
</body>
</html>

What happens is it will display a 0 (zero) followed by the actual contents
of the file. I added the include command just to see if I could access the
file from the root directory. Sort of to test the permissions and such. It
works, but again the file size is coming out as zero. HELP please. Thanks
for any suggestions, I am still very new to PHP.

Lee A. Wentzel


Reply With Quote
  #2 (permalink)  
Old 06-05-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: Filesize problem.

Lee A. Wentzel wrote:
> I am trying to determine if a file contains information. I thought
> the easiest way to do this would be to check the files size. So I
> wrote the following code.

[...]
>
> <?php
> $file_size = filesize("manager/coupon.inc");
> echo "file size=" & $file_size;
> include("manager/coupon.inc");
>>


An ampersand (&) is a bitwise operator in PHP. What you really need is
either a dot to concat the parts or a comma (does not work with print):

echo "file size=" . $file_size;
echo "file size=", $file_size;

Or simply:

echo "file size=$file_size";


JW



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:41 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0