Cameron Garnett/Testpage4
Contents
Super Quick PHP Tutorial
Introduction | Basic Syntax | Sending Data to the Browser | Comments | Variables | Strings | Functions | Quotes | Debugging | Form
Learning ObjectivesBy the end of this page you will know how to set up php and some of the basic syntax used, when you are dealing with php code. |
What Do I Need?
To start using PHP, you can:
- Find a web host with PHP and MySQL support
- Install a web server on your own PC, and then install PHP and MySQL
- Use a Web Host With PHP Support
If your server has activated support for PHP you do not need to do anything. Just create some .php files, place them in your web directory, and the server will automatically parse them for you. You do not need to compile anything or install any extra tools. Because PHP is free, most web hosts offer PHP support.
Set Up PHP on Your Own PC
However, if your server does not support PHP, you must:
- install a web server
- install PHP
- install a database, such as MySQL
- The official PHP website (PHP.net) has installation instructions for PHP: http://php.net/manual/en/install.php
Basic Syntax
Amazing objectivesBy the end of this page you will be able to:
|
Getting Started: A PHP script starts with <?php and ends with ?>:
<?php PHP code goes here ?>
Write this block of code into note pad ++ and save the file as example.html
At the end of each statement or line it is important that you have a semicolon ; that represents the end of a line
Case Sensitive
In PHP classes, functions, and user-defined functions are NOT case-sensitive. For example
Example<!DOCTYPE html> |
All 3 echo statements are true and will work because the echo function is not case-sensitive.
It is different when you are working with a variable name. You must be careful because these are case-sensitive. For example
Only the first echo statement is true this is because ($weather, $WEATHER and $weaTHER) are treated as 3 different variables.