note 91829 deleted from function.filesize by danbrown
| From: | danbrown@php.net | Date: | Fri, 26 Jun 2009 20:23:36 +0000 |
| Subject: | note 91829 deleted from function.filesize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157618@lists.php.net to get a copy of this message | ||
Note Submitter: tmpa at yahoo dot com
----
@Anonymous
Re: Shortest solution to get filesize of a remote website
It would be better to use strlen() instead so you don't have to write a temporary file and
incur that extra overhead since the content is already in memory.
<?php
$size = strlen(file_get_contents("http://www.example.com"));
?>
This was basically suggested by revoke, but no need to use file() and join() when you can just use
file_get_contents() (unless you have an old version of php of course).