"Sims" <siminfrance@hotmail.com> wrote in message
news:c6174b$6eq6p$1@ID-162430.news.uni-berlin.de...[color=blue][color=green]
> >
> > PHP is server-side - the file size of the PHP script has absolutely no
> > correlation to the amount of data sent to the user's browser. You could
> > easily write a tiny PHP script that could send megabytes of data to a
> > user's browser.
> >
> > eg.
> > <?php
> > for( $i=0; $i<1000000000; $i++ ) {
> > echo "Here's some data<br>";
> > }
> > ?>
> >
> > Ultimately, the size of what the user will receive in their browser
> > depends on the
> >
> > 1) The size of the generated HTML
> > 2) embedded/linked content within that HTML file - images, flash, movies
> > etc.
> >
> > So are asking how using PHP you can calculate the total of #1 & #2 for a
> > given script output?[/color]
>
> But as a server side operation php create something that will be sent to[/color]
the[color=blue]
> browser, (HTML page, links etc).
> So yes I would be curious to see the size of what is sent, (including
> images).
>
> But I realise that it is not an easy task but using
>
> <?php
> for( $I=0; $i<1000000000; $i++ ) {
> echo "Here's some data<br>";
> }
> ?>
>
> I can guess how big the final output will be, (and add the size of[/color]
images).[color=blue]
>
> With the size I could then make an educated guess if the pages is too big
> and needs to be trimmed.
>
> Sims[/color]
Use output buffering and use ob_get_length to get the size of the data being
streamed. Note that your images are actually separate retrieves. Most like
you are including <img> tags. Right? As such, you will output a stream of
html and the browser will then make an additional request to get the actual
image. You could determine what images will be requested as you build the
html and then get their sizes and add them to the size of the html you find
in the output buffer.
See
http://us2.php.net/manual/en/ref.outcontrol.php for more info on output
buffering/control.
- Virgil