-1

hi im new to php programming .it is not clear in my mind how the execution happens and what follows next. I want to understand clearly how a php file is executed and where is the request sent and is the output file in html ,basically all the steps from executing a php file to getting the output file.

sumit
  • 15,003
  • 12
  • 69
  • 110
avinash
  • 119
  • 1
  • 7
  • Basic PHP Tutorial : http://www.w3schools.com/php/default.asp or Install Wamp server then create file test.php then run this file in browser as http://localhost/test.php – Zeeshan Jan 27 '14 at 04:55
  • 2
    http://stackoverflow.com/questions/2720488/how-exactly-is-a-php-script-executed – sumit Jan 27 '14 at 04:57

1 Answers1

1

Here are the very simplified steps:

  1. The web server recieves a request.
  2. It checks the resource requested.
  3. It tries to find the resource as per its configuration. Part of this configuration is that all requests that match the pattern *.php should be sent to the PHP interpreter.
  4. The webserver passes the request to the PHP interpreter (which is a module configured for the webserver, or a separate binary, depending on how the web server is configured).
  5. The PHP interpreter reads the request, then executes the file by interpreting it top to bottom, line by line.
  6. The results are sent back to the web server, which passes the results to the browser.
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
  • One thing to note is that PHP doesn't "know" that it's working with HTML. In fact PHP is commonly used to output images. It can even generate PDFs, or heck even entire videos if given the right code! – Niet the Dark Absol Jan 27 '14 at 05:04