Jump to content

Archived

This topic is now archived and is closed to further replies.

colfaxrev

get the size of the output of a php file?

Recommended Posts

Is there a way of getting the final size in bytes of the output of a php file?

i have a separate php file that is doing the following...

[code]
print "filesize[" . filesize('roro3.flv') . "]";
[/code]

which outputs...
filesize[18492343]

so that works fine...

I want to get the FINAL size in bytes for the output of a php file... i tried this (which i was sure wouldn't work)

[code]
print "filesize[" . filesize('tracking.php?action=show') . "]";
[/code]

You can see that file for youself here...
http://triotalentagency.com/newsite/tracking.php?action=show

but that code prints out this...

filesize[]

i also tried to use readfile() but that didn't seem to work....
is there anyway to do this?

thanks!

Share this post


Link to post
Share on other sites
if you are trying to find the size of the output of a page that will always be a constant size you can probably do this:

[code]
$site = file_get_contents('http://www.mywebsite.com/tracking.php?action=show');
print "filesize[" . strlen($site) . "]";
[/code]

I believe that "filesize" only works for local files, so "filesize('http://www.mywebsite.com/tracking.php?action=show')" wouldn't work. Since 'http://www.mywebsite.com/tracking.php?action=show' is clearly not local.

Also, if what you were attempting to do was to retrieve the file locally, the script would be looking for a file named 'tracking.php?action=show', not a file named 'tracking.php'.

(Also retreiving a php file locally gets the code of the file, not the output. ie: filesize("helloworld.php") would get the length of "<?php echo 'Hello World'; ?>" rather than the length of "Hello World")

Share this post


Link to post
Share on other sites
::test1.php::
[code]<?php

for($i=0; $i<250; $i++) echo 'x';

?>[/code]

::test2.php::
[code]<?php
 
  ob_start();
  include('test1.php');
  echo strlen(ob_get_clean());  // --> 250
 
?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.