by glitzi85 » 05. March 2011 00:26
I do not fully understand what you write, but that's how it works:
When you request a website to Apache with your Browser, Apache tries to load that file from the hard disk. It recognizes that it is a PHP file and sends the file to the PHP parser. The output of the parser is then sent back to the browser. That's it from the Apache point of view. Everything that is written in PHP inside of your php files is executed by the php parser, including connections to databases.
You can compare this with ordering an burger:
You walk into a store and order an burger (Request from Browser to Apache)
The guy at the desk is checking if there is already a burger ready (Apache delivering static files like images or html files)
or he needs to get a new one. In this case he passes your Order to the cook (Apache requests PHP to parse the php file)
The cook does not have everything, so he asks his helper to cut the salad (PHP request data from a database)
The helper gives the salad to the cook, which puts it onto the burger (PHP get's data from database)
The cook is giving your burger to the guy at the desk (PHP passes it's output to Apache)
You get your burger (Apache delivers the output to the Browser)
glitzi