colfaxrev Posted October 27, 2006 Share Posted October 27, 2006 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=showbut 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! Quote Link to comment Share on other sites More sharing options...
ksteuber Posted October 28, 2006 Share Posted October 28, 2006 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") Quote Link to comment Share on other sites More sharing options...
Barand Posted October 28, 2006 Share Posted October 28, 2006 ::test1.php::[code]<?phpfor($i=0; $i<250; $i++) echo 'x';?>[/code]::test2.php::[code]<?php ob_start(); include('test1.php'); echo strlen(ob_get_clean()); // --> 250 ?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.