Archive for category PHP

PHP Basics

Heres a quick intro to PHP. A lot will be left out, I’m assuming you know basic programming (variables and loops). W3 Schools is a great place to learn PHP more in depth.

To try this code make sure you have XAMPP installed, check out this tutorial if you haven’t set it up yet.

Every script should begin and end with the php open/close tags.

 
< ?php 
//Comments
//rest of code here
?>

Here are some examples

 
< ?php
// two backslashes are used for comments
// A variable is created using the dollar sign before the name of the var
$v1 = "bananas" ; //semicolon after each statement
 
//echo is used to print to the screen
echo $v1;
 
//You can print multiple items using a comma
$v2 = "apples" ;
echo $v1, $v2;
 
//If statements are similar to those in C++ and Java.
$uno = 1 ;
$dos = 2 ;
 
if($uno < $dos)
{
  echo "WOO!" ;
}
else
{
  echo "WTF!?";
}
 
?>

Read the rest of this entry »

3 Comments