What happens when a php script is executed?

Hi;

Lets say I write this simple script:

<?php
echo "Hello";
?>

When I call the script (either from browser or terminal), is this what happens?

1 - The computer converts this to an executable which is only zero and ones,
2 - Creates the out put as zeros and ones,
3 - Converts the zeros and ones to an out put and shows the results.

Correct? Can someone please briefly explain

Thanks

This might help you find an answer: https://www.google.com/search?q=php+execution+steps

That search that Force Flow has provided is great. In a very, very simple way, this is what happens

  1. User requests php page (either by writing the name on the address bar or clicking a link)
  2. browser send requests to the web server (Apache or whatever)
  3. web server recognises the extension and sends it to the php parser
  4. php parser do its magic and executes all php in the page, line by line
  5. The result is returned to the web server
  6. The web server sends it back to the user’s browser

[ot]That query url is essentially meaningless as everyone’s query results will be different.

http://searchengineland.com/guide/seo/personalization-search-engine-rankings[/ot]

[ot]I agree up to a point. I think that what Force Flow meant was that if he searched Google, he may find an article with a detailed and clear explanation :slight_smile:

And even if the results do vary from computer to computer, it is very likely that at least one of those links will have that information[/ot]

[ot]Maybe, but it negates the value of having a forum if the answer to questions is go search Google. Its much easier to do a Google search than post on a forum so it does the forum a disservice.

I have no problem with posts with links that say here is the answer to your question. I don’t see the value in posts that are not answers but simply saying (or implying) don’t ask your question here, ask Google. This forum won’t last long if it thinks those are real answers.[/ot]

Here is a small slideshow of how PHP code is interpreted. It really isn’t line by line…

Much more than you will ever need to know unless you plan on writing extensions or contributing to core.

Here is another good read breaking down source.

http://www.phpinternalsbook.com/index.html

[ot]I understand your point but it is also true that certain questions need such a detailed explanation that it is better to read an article than ask in a forum, furthermore when the answer is easy to find.

If you’re gonna post in a forum, it is better that you say something like “I’ve read this article but I really don’t understand this and this”. [/ot]

Naturally no one has got this right.

When you browse the page there’s magic going down and unicorns sneezing on the php code which wonderfully returns a web page through unknown means, though I’m putting it down to those meddling Smurfs.

[OT]One of the things Jeff Atwoods achieved, at least some of the time, is a Q&A forum (stackexchange) which gets constructive dialogue going even when the original post is lacking in cpmpleteness in terms of its problem description. Thats why they have managed to achieve outstanding Google ranking. We still seem to be making the same mistakes here.

[I do however disagree with Jeff Atwood’s philosophy of community for other reasons but he did seem to get some things right.][/OT]

Off Topic:

@Kiwiheretic; Maybe you’re right and we’re failing to create a nice and good discussion even on a repetitive topic.

Off Topic:

Much better to point them to a post on sitepoint that already answers the question. To me its about community. Are we pushing people off the site onto other sites or are we encouraging people to stay? Sitepoint needs to clarify its thinking on this.

Off Topic:

We should open another thread to discuss this, don’t you think? We’re so off-topic on this one! :slight_smile: Do you want me to move these posts to a new thread?

I think to understand this whole system you need have great knowledge of Compilers.

I disagree. PHP is not a compiler.