Show Menu
Cheatography

PHP - Variables Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Variables - Naming & Types

$name = "­Jim­";
string
$number  = 23;
number
$Float  = 55.67;
float
$_included = true;
boolean
$stuff­_array = ["st­rin­g", 44, false];
array
$nothing2 = null;
null
Naming: Variables can only contain numbers, letters, and unders­cores, although they must begin with a letter or unders­core. They are case sensitive.

Types: Variables can store the data types string, number, float, boolean, array, and null.

Glossary

string interp­olation
embedding variable value in a string
concat­enation
joining two strings end to end
casting
the process of transf­orming from one data type to another
 

Variables - Modifiers

Set the value of the variable to its current value plus 5
$number += 5


Increment the variable value by 1
$number++;


Decrement the variable value by 1
$number--;