PHP: Basics

In this tutorial I will explain:
•Opening and closing tags of PHP…
•Other basic tags…
•And an example of a PHP page.

The only way of starting a PHP script is to first type <?php. The content goes in between that tag and the ending tag which is, ?>.

Example:

  1. <?php
  2. /* This is a comment block */
  3. echo ‘Hello World’;
  4. ?>

A comment block is any text that you would like to include in a PHP page without it having an affect on the page itself. You can use comment blocks to help you locate information in a certain page so that your not scrolling for such a long time looking for a certain part of the page.

The text ; is used to end a string or anything and everything in a PHP script. You must use this to declare the end of every statement (Declaring variables, Echoing, etc..).

Echo is a function used to output text and data. You use it to display variables, strings, and even HTML code. When you start to echo something you do it as follows: echo ‘ content to be displayed goes here’;. Don’t forget to end the statement with a semi-colon.

1 Comment so far »

  1. Coding College » The 7 Ultimate Reasons To Learn PHP said

    am April 22 2008 @ 6:24 pm

    […] tons of tutorials out there; I suggest starting out with an introduction to PHP, then moving on to PHP basics. If you can’t find what your looking for on CodingCollege just leave a comment and we will […]

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: