michlcamp wrote:simple things like double "+" signs,
++ is an increment operator used on integers.
For example:
It can be done post-increment ($i++) or pre-increment (++$i). For the most part it doesn't affect anything but if you have the ++ as part of another statement the difference comes into play.
$i++ is post-increment and it means that the value of $i is read BEFORE it is incremented. So in the excerpt:
Code: Select all
$i = 5;
if ($i++ == 5) echo "i is 5"; //This prints since $i is read BEFORE incrementing
//$i is now 6
++$i is pre-increment and means that $i is incremented and THEN read.
So the same code above no longer prints "i is 5" since it is 6 before the comparison is made:
Code: Select all
$i = 5;
if (++$i == 5) echo "i is 5"; //This never prints since $i is 6
//$i is now 6
and specifically this one...
It's an object operator. Objects are instances of classes. Classes are containers for a set of values on some actions to perform upon them. So in the simple class:
Code: Select all
class Foo
{
var $name = "My name";
function getName()
{
return $this->name;
}
}
$obj = new Foo();
echo $obj->getName();
$obj is an instance of "Foo". Foo contains a variable (technically its a "property") $name. To access $name inside Foo you would use the "->" operator. To access the function (technically it's a "method") "getName()" inside Foo you also use this operator.
The reason you see $this is becuase it's a special case. From
inside any class you can refer to the instance of the object that's been created from it by using $this just like we used $obj outside of the class.
Also don't know how to interpret this (or similar):
Does it mean "If not $j, then $j = zero?
You're right. ! is a negation operator. It turns a boolean (true or false) value into it's opposite. In the case where you say:
It's basically "if not 1" but to be picky it really means "if the value of 1 is NOT true". So this does what?
Code: Select all
if (!(!1)) echo "Condition valid";