Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "++" mean in PHP? [duplicate]

Tags:

php

Possible Duplicate:
Reference - What does this symbol mean in PHP?

I've been learning PHP by reading all sorts of things on the web. I've trying to figure out what this is called so I can look it up and read about it and learn how it works. It's the "++" in the code I'm assuming counts up so that the codes knows when to do a new line. I not looking for corrections to this code I'm looking for what the "++" is called so I can look it up.

$i = 0
if (++$i == 10) {
    echo "new line";
}
like image 627
Warmour Avatar asked Feb 25 '26 11:02

Warmour


1 Answers

It's called the prefix increment unary operator. It increments the number or character, then returns its value.

The postfix version does pretty much the same but returns its value first, then increments the variable.

like image 99
alex Avatar answered Feb 26 '26 23:02

alex