PHP Basics

PHP PHP is a programming language, designed to make programming web pages easy
Statement A statement is one sentence in a programming language. A PHP statement always has a semicolon after it: $count = 1;
Variable A PHP variable is something that can hold a value. In the example above, the variable is $count and it is set to have the value 1.
PHP variables always start with $.
Values A PHP variable can hold several types of values. It can hold numbers ($count=1; $price=1.23;) or strings of characters ($name = "bobobo";) or a true or false value ($answer=true;)
Arrays A variable can also hold more than one value, known as an array.
$a = array(1, 2, 3);
  • you can ask an array its length: $length = count($a);
  • you can get a value from an array: $first = $a[0];
  • some arrays have named items: $first = $a[first];

Home