Jump to content

understanding php processing and page output order


vanderlay

Recommended Posts

Hi All,

 

I have been using php for some time now and have got the hang of fairly high level processing including dynamic images from mysql output that leads me to the point of needing to better understand the processing /logic order of the php engine so i can increase the speed of my scripts.

 

so the Q i have is how is the following rendered by php,

 

template.php

                require -> mysqldata.php to get info from db

                require -> imagegd.php takes mysql data and var from template.php and resizes image then outputs to browser(no save)

 

Q1. a)does template.php have to wait for mysqldata.php to be fully rendered/computed before moving on to imagegd.php or

      b)does imagegd.php get called immediately and has to wait for mysqldata.php to supply the info needed (i presume the (a) is correct)

 

Q2. once imagedgd.php has been called and an image generated is that image pushed to the browser or is the template.php rendered as html sent to browser and the browser then requests the imagegd.php script and the image is generated.

 

Q3. is there a good way ( i have tried  ob_start("ob_gzhandler"); ) to buffer the page and wait for all images but it only seems to work on text/layout rather than graphics/fla etc.

 

thx

Art

 

 

Link to comment
Share on other sites

PHP is processed line by line..... The entire thing is compiled, and then it's executed in the order it was in....

 

You're basically asking if you did echo "hello"; echo " people"; whether people would be echo'd before hello was done processing if I understand right, and no, it does not work like that (I could be wrong, but I'm fairly sure ;p).

 

If it worked like that, then a SQL query could try to query a lagging DB link or something like that.

 

As for your second question.....  PHP cannot output an image and HTML on the same page... Well, it can but it will not display correctly.

 

That would be like if you tried to make a plain HTML page and put an image in it without an <img> tag.

 

Question 3:

 

I've seen parts of what you're trying to do done with javascript, but PHP with buffering does this:

 

Generate page conent

Send to browser.

 

If the download speed or what ever other barrier gets in the way, it's the exact same loading as a plain HTML page would be.

Link to comment
Share on other sites

to john010117, please check your facts before having a go at some body...i did wait at least an hour before bumping

 

A.M.  abbreviation ante meridiem

Meaning: being before noon

 

P.M.  abbreviation post meridiem

Meaning: being after noon

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.