22mafia Web Tutorials

Just another WordPress weblog

 

PHP Basic’s – Echo and “Hello World!”

Posted on January 19th, 2010 by admin

Today 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.

PHP Basic’s – Getting Started

Posted on January 17th, 2010 by admin

Understanding what PHP is, and what it is used for is important, but not to me.

To start I am going to assume that you know why you would like to learn PHP and hopeful have a basic understanding of HTML. The main reason you need an understanding of HTML is because PHP is nothing more than a medium for delivering HTML to the clients browser.

A few other things you may need to move forward with coding PHP

  • A text or HTML editor (TextWrangler, Dreamweaver, jEdit…)
  • A test platform (Server, MAMP [Mac], Apache…)

You may need more, but thats your problem.

 
 
 

Copyright © 2009 22mafia Web Tutorials. Theme by THAT Agency powered by WordPress.