PHP Increment and Decrement Operators - Part 2
Notes:
PHP Increment and Decrement Operators - Part 2
Increment and Decrement Operators: are used to increment or decrement a variable value by 1.
++ : Increment Operator : is used to increment a variable value by 1
Post Increment : variableName ++
Pre Increment : ++ variableName
-- : Decrement Operator : is used to decrement a variable value by 1
Post Decrement: variableName --
Pre Decrement : -- variableName
Example code2:
// actual code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",$a++,"<br/>"; // 10
echo "a=",$a,"<br/>"; // 11
// behind the scene code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",$a=$a,"<br/>"; // 10
$a=$a+1; echo "a=",$a,"<br/>"; // 11
// actual code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",++$a,"<br/>"; // 11
echo "a=",$a,"<br/>"; // 11
// behind the scene code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",$a=$a+1,"<br/>"; // 11
$a=$a; echo "a=",$a,"<br/>"; // 11
// actual code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",$a--,"<br/>"; // 10
echo "a=",$a,"<br/>"; // 9
// behind the scene code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",$a=$a,"<br/>"; // 10
$a=$a-1; echo "a=",$a,"<br/>"; // 9
// actual code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",--$a,"<br/>"; // 9
echo "a=",$a,"<br/>"; // 9
// behind the scene code
$a = 10;
echo "a=",$a,"<br/>"; // 10
echo "a=",$a=$a-1,"<br/>"; //9
$a=$a; echo "a=",$a,"<br/>"; // 9
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a