Memory App
 



Building memory bonds
Php  >     ZCE 5.3  |  Patterns  |  Modern Php Php   >   Variables   >   Variable definition

Loosely typed

PHP is loosely typed, meaning that it will implicitly change the type of a variable as needed, depending on the operation being performed on its value. This contrasts with strongly typed languages, like C and Java, where variables can only contain one type of data throughout their existence.

Naming

Variables must be named using only letters, numbers and underscore. Must start with a letter or an underscore.

$name = 'valid'; // Valid name
$_name = 'valid'; // Valid name
$1name = 'invalid'; // Invalid name, starts with a number

Case-sensitive

Are one of only two identifier types in PHP that are case-sensitive (the other is constants)

error_reporting(E_ALL);

$Name = "John";
echo $name; // Notice: Undefined variable: name