And also please tell whether PHP code is >compiled first or iterpreted like HTML or >PERL-CGI
I believe this is the correct order of how php works, from first to last:
Client requests index.php (for example).
Server parses index.php (finds syntax errors and the like).
Server executes index.php, meaning any "work" it has to do is then performed (like multiplication, addition, fread(), etc.).
Server compiles index.php into html code and sends it out to the Client.
One must remember that the browser handles PHP pages as nothing more than HTML/java/DHTML. But I'm assuming you already knew that 🙂
There are most likely other steps than what I listed, but that's the basic gist.
Note: the entire page is not neccesarily handled all at once. Meaning an early part of your code may of already been sent to the client while the rest of your code is still at work. Thus why you have to remember to stick header() and the like before any other information that would be sent to the browser.
PHP is smart, but it's not a rocket scientist 🙂