Php program to print the number using post decrement

A Php program to print the number using post decrement. In this program we can print the number using the post decrement operator. A post-decrease operator is used to decrement the value of a variable after executing the expression in which the operator is utilised. The variable’s value is used in an expression before being decremented using the post-decrement operator.

<?php
$x = 10;
echo $x--;
?>

 

Output:

10

What is purpose of post decrement operator in php

After an expression has been fully executed, the post-increment operator is used to increase the value of a variable. In the Post-Increment, value is first used in an expression and then incremented. If the operand is a pointer, the operation subtracts 1 from the value of the scalar operand, or increases the operand by the size of the object to which it points.

Diffrence between post increment and post decrement in php

The distinction is: ++ I will update the value of the I variable and return it, whereas $i++ will return the original value, hence increment it. The term “post-increment” refers to the use of $i++. After allocating the original value of I to $j, it increments the value of $i. ++ Pre-increment is referred to as $i.