Ringkasan ini tidak lengkap dalam arti kondisi spesial tidak dimasukkan, tapi cukup lengkap secara keseluruhan. Bisa digunakan sebagai referensi untuk syntax dan cara pemakaian.
Prinsip
Weak type - no need to declare variable data type
Not case sensitive kecuali nama variabel
Nama variabel selalu diawalin dengan dollar sign, $
Tiap statement harus diakhiri dengan semicolon, ;
Array index mulai dari 0
Auto garbage collection for resource data type - memory yang sudah tidak dipakai oleh resource akan free sendiri. Tidak untuk array.
string - declare pakai single quote 'x', double quote "x" untuk variable substitution, heredoc, atau nowdoc
array - *index mulai dari 0 *indexed atau associated array (key-value) *index, key dan value boleh integer atau string $arr = array("foo" => "bar", 12 => true); //sama dengan
$arr["foo"] = "bar";
$arr[12] = true; • Pakai unset() untuk lepaskan memory yg dipakai oleh array.
object
resource
null - belum di assigned nilai, di assigned dg null atau sudah di unset(). Gunakan is_null() untuk cek.
pseudo types: mixed, number, callback
Variable Scope
local - inside function
global - declare outside function
static -- inside function, static $a=0;
Variable variables
variable with variable name. $a='hello'; $$a='world'; --> same as $hello='world'; Note: use curly bracket to avoid ambiguity: ${$a}