Getting Started with PHP – Part 2

Guest Posts Paolo Nikko Nuñal

Why PHP?

PHP can run on different platforms such as  (Windows, Linux, Unix, Mac OS X, etc.) and is compatible in almost all types of servers APACHE, IIS and the like.

Getting Started

Before you can start programming in PHP you need to have a web host that supports PHP and mySQL. In this tutorial you are going to set-up PHP on a localhost and that means you are going to use your computer.

To set-up in your PC is easy. And all you need is to download either WAMP server for Windows.

The official PHP website also offers a step by step guide on installing that you can find it here.

You can download WAMP through here

If you managed to install WAMP on the default location that is 'C:\wamp\'. The 'www' folder is the place you should store your php files inside.

Learning the Basics

PHP can run almost anywhere on a web page as long as the file is a '.php' file. PHP files normally contains HTML files, but sometimes been integrated in JavaScript, or purely PHP files.

To start with a php script, you need to start with a "<?php" as your starting tag and end with a "?>".

Syntax:

<?php //INSERT CODE HERE ?>


Whatever you put inside those tags will be php script.

Here's an example with a combination with HTML tags.

Syntax:

<html>
<head>
   <title>My First Web Page</title>
</head>
<body>
   <?php echo "Hello World"; ?>
</body>
</html>


From the example above you can see that we have integrated PHP code inside an HTML file. The "echo" syntax is actually a way of printing something that you wish to output in the browser. Don't forget  to terminate every php line of code with a semicolon ";".