= 1` in my PHP document mean?

I have the following variable defined in a PHP document I am working with, and I'm unsure what it means.

The PHP

$page -= 1;

The part I am unsure of is the -=

Thanks!


The -= operator is shorthand for subtracting a value from the variable:

$x -= 1;
$x = $x - 1;

Here's some of the other ones:

  • $x += 1; ( $x = $x + 1 )
  • $x -= 1; ( $x = $x - 1 )
  • $x *= 1; ( $x = $x * 1 )
  • $x /= 1; ( $x = $x / 1 )

  • It's a shorthand to save typing. It's effect is idential to

    $page = $page - 1;
    

    The -= operator is a combination arithmetic and assignment operator. It subtracts 1 then reassigns it to $page .

    链接地址: http://www.djcxy.com/p/1826.html

    上一篇: 了解增量

    下一篇: = 1`在我的PHP文件中是什么意思?