Pre Decrement in PHP

Pre decrement in php. In this program we can print the number using pre decrement in php. The increment operator is used to increase the value by one, while the decrement operator is used to decrease the value by one. The increment operator reduces a value by one.

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

 

Output:

9

Pre Decrement in PHP

PHP supports pre- and post-increment and decrement operators in the C manner. Only numbers and strings are affected by the increment/decrement operators. The symbol ‘—’ stands for the decrement operator. Both prefix and postfix notations are supported by the decrement operator. The value of a variable is utilised in the expression after it has been decremented in prefix notation. Pre-increment means that the value is increased by one before being assigned to the variable.

Echo in PHP

The PHP echo command may be used to output a string, multiple-line strings, escaping characters, variables, arrays, and so on. The statement echo is used to display the output. echo() and echo can be used with or without parentheses. There is no value returned by echo.