minte9
LearnRemember



Type

PHP will implicitly change the type of a variable as needed (loosely typed).
 
/**
 * PHP will implicitly ...
 * change the type of a variable as needed
 * 
 * This contrasts with strongly typed languages, 
 * like C and Java
 */

$a = "abc";
$b = 0 + "1";
$c = new ArrayObject();

echo gettype($a); // string
echo gettype($b); // integer
echo gettype($c); // object

Naming

Variables must start with a letter or an underscore.
 
/**
 * Variables must be named using only ...
 * letters, numbers and underscore.
 * $name_/ - invalid name
 * 
 * Variables must start with a letter or an underscore
 * $1_name - invalid start
 */

$name = 'valid'; // valid name
$_name = 'valid'; // valid start

Case

Variables names are case sensitive.
 
/**
 * In PHP Variables are one of only two identifier types ...
 * that are case-sensitive
 * 
 * The other are constants
 */

$Name = "John";
const NAME = "Bob";

var_dump(isset($name)); // false

//echo name;
    //Undefined constant: name



  Last update: 233 days ago