PHP Basic’s – Echo and “Hello World!”
Posted on January 19th, 2010 by adminToday we are going to cover the vary basic’s of PHP.
To start you are going to need some basic HTML in a file with a PHP extension. I’m going to start with this…
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Test Page</title> </head> <body> </body> </html>
If we are going to write PHP, we need PHP tags. Those can be placed anywhere on the page, but we are going to place ours inside the body tags.
<body> <?php ?> </body>
The next concept to understand is that PHP is nothing more than a method of serving HTML. This just means that your final product needs to be HTML. So, we will do next is the classic “Hello World” statement. The call for rendering text to the browser is “echo” in PHP.
<body> <?php echo "Hello World"; ?> </body>
Another thing to notice from the code above is the the statement ends with a semi-colon. Every line in PHP has to end in a semi-colon.


