PHP-Basic Development Concepts
When developing a PHP application for Web, the typical approach is to embed PHP code into one or more standard HTML documents using special “tags”, or delimiters.
Here’s an example:
1 2 3 4 5 6 7 |
<html> <head></head> <body> <div> <?php echo "Welcome to PHPGurukul"; ?> </div> </body> </html> |
- Joe pops open his Web browser at home and types in the URL to a Web site. After looking up domain, Joe’s browser(the client) sends an HTTP request to the corresponding server IP address.
- The Web server handling HTTP request for the domain receives the request and notes that URL end with a .php suffix. Because the server is programmed to automatically redirect all such requests to the PHP layer, it simply invokes the PHP interpreter and passes it the contents of the named file.
- The PHP interpreter parses the file, executing the code in the special PHP tags. Within these tags, you can perform calculations, process user input, interact with a database, read and writes files… the list goes on! Once the script interpreter has completed executing the PHP instructions, it returns the result to the browser, clean up after itself, and goes back into hibernation.
- The results retuned by the interpreter are transmitted to Joe’s browser by the Web server.
- A base operating system(OS) and server environment(usually Linux).
- A Web server(usually Apache on Linux or IIS on Windows) to intercept HTTP requests and either serve them directly or pass them on to the PHP interpreter for execution.
- A PHP interpreter to parse and execute PHP code, and return the results to the Web server.
- A database engine(such as MySQL) that hold application data, accepts connections from the PHP layer, and modifies or retrieves data from database.