PHP Increment and Decrement Operators - Part 1
Notes:
PHP Increment and Decrement Operators - Part 1
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 code1:
$a=10;
echo "a=",$a,"<br/>"; //a=10
$a++; // $a=$a; $a=$a+1;
echo "a=",$a,"<br/>"; //a=11
$a=10;
echo "a=",$a,"<br/>"; // a=10
++$a; // $a=$a+1; $a=$a;
echo "a=",$a,"<br/>"; // a=11
$a=10;
echo "a=",$a,"<br/>"; // a=10
$a--; // $a=$a; $a=$a-1;
echo "a=",$a,"<br/>"; //a=9
$a=10;
echo "a=",$a,"<br/>"; // a=10
--$a; // $a=$a-1; $a=$a;
echo "a=",$a,"<br/>";//a=9
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a