Example 1 - Hello World in PHP
Following a long tradition of introductory programming and scripting tutorials, our first example will print "Hello World" in the browser window.
<HTML> <HEAD> <TITLE> Hello World in PHP </TITLE> </HEAD> <BODY> <? // Hello world in PHP print("Hello World"); ?> </BODY> </HTML>
The PHP statement:
<? print("Hello World"); ?>
displays the message "Hello World" in the browser window. As was mentioned earlier, PHP statements are embedded into HTML documents and they appear between <? and ?> symbols.
Several important things to note about PHP scripts: