订购php脚本执行

The problem

My initial php script looked something like this:

echo "text"; // display text
echo "<img src='displaypic.php'>"; // display pic
echo "text";  // display text

I observed that when loading the page the text was displayed first (after 1 or 2 seconds) then the pics (it took a bit longer). That was pretty fine because users were never in front of a blank page.

Later I added a script for displaying a flash pie chart (found the script on Open Flash Chart):

echo "text"; // display text
echo "<img src='displaypic.php'>"; // display pic
echo "text"; // display text
include 'piechart.php'; // display flash chart

It works fine but... all visual content (text, pics, chart) is displayed at once. The problem is that it takes about 10 sec. to load and I think it is just too long.

What I would like to do

Ideally I would like to have text displayed first, followed by pics and chart so users are not in front of a blank page. Is there a simple way to do that? Thanks.

Your question isn't related to PHP execution. Because php usually compiles and executed on server side before your server sends any data to client side. So when you see any result on your webpage it means your php script already completely finished running.

On the other hand displaying some elements first related to how a browser renders html, javascript and css so you can find a solution in those. Changing your table/div etc structure , putting include files to correct positions will make a change about your expected result. But don't forget It can also varies depending on what browser you are using while testing your site.