|Lessons||PHP First Program|
What is a PHP File?
PHP files may contain text, HTML tags and scripts. PHP files are stored on the web server. PHP files have a file extension of ".php", ".php3", or ".phtml". .php is often preferred. A PHP script is run on the web server and not on the user's browser. Therefore, client-side compatibility issues are not of concern of the programmer as the server side script simply returns an HTML document for the user's browser to render. We need three things to make this work: the PHP parser (CGI or server module), a web server and a web browser.
PHP Hello World
Following is our first PHP Hello World program.
<html> <head> <title>PHP Hello World</title> </head> <body> <?php // start of php code echo '<p>Hello World</p>'; ?> </body> </html>The code written within "php" tags is parsed by the PHP processor and the rest is ignored. Hence, a PHP parser would convert the above code into the following HTML document and send it back to the browser.
<html> <head> <title>PHP Hello World </title> </head> <body> <p>Hello World</p> </body> </html>Points to Remember:
Next: PHP Variables