WORKING WITH VARIABLES
email
abc@gmail.com
customerDOB
3/9/92
imagePosition
x : 20
y : 300
imagePosition
120000
CREATING VAERIABLES
$year;
$customerEmail;
$todaysDate;
$foo;
$x;
letters
numbers
_
$99problems
$problems99
CREATING VAERIABLES
$year;
$year = 2013;
NULL
year
2013
VARIABLE NAMES ARE CASE SENSITIVE
$x = 200;
$X = 200;
x
200
X
200
email
abc@gmail.com
customerDOB
3/9/92
imagePosition
x : 20
y : 300
imagePosition
120000
WEAK TYPING
$myVariable;
myVariable
$myVariable = 200;
$myVariable = “Hello”;
$myVariable = ‘Hello’;
$myVariable = true;
$myVariable = false;
200HellofalsetrueNULL
STRINGS
echo “Hello, World!”;
$message = “Hello, World!”
echo $message;
WORKING WITH STRINGS
$myString = “Double quotes work.”;
$myString = ‘Single quotes work too.’;
$myString = “ One or other. ’;
QUOTES INSIDE QUOTES
$phrase= ‘ Don’t mix your quotes.’;
$phrase = “ Don’t mix your quotes.”;
$phrase = “He said “that’s fine,” and left.”;
$phrase = “He said “that’s fine,” and left.”;
USING OPERATORS
ASSIGNMENT OPERATOR
= 500;$balance
ARTHIMETIC OPERATORS
+ - * /
$a = 100;
$b = 50;
$a $b;=$result
150
+-
50
*
5000
/
2
OPERATOR PRECEDENCE
$result = 5 + 5 * 10;
505 +55
OPERATOR PRECEDENCE
$result = (5 + 5) * 10;
* 1010100
ARTHIMETIC OPERATORS
$score = $score + 10;
$score += 10;
+= -= *= /=
INCREMENT / DECREMENT
$a = $a + 1;
$a += 1;
$a++;
$a = $a - 1;
$a -= 1;
$a--;

Working with variables in PHP