Possible Duplicate:
Reference – What does this symbol mean in PHP?
When I use a function I use standard return statements.
I mean by that that I usually either return true or false or a variable. Nevertheless I am currently following a tutorial which I understand pretty well beside the return of the here below function.
I do not get how to read the question mark the two dots….
public function someFunction()
{
return null === $this->anAttribute ? null : $this->aFunction();
}
Return
nullif$this->anAttributeisnullelse return$this->aFunction()?:called ternary operatorWriting
nullin first place is used for avoiding wrong assignments typo, likeif ($a = null). If you get used to writing functions and constants firts this will lead to errorif(null = $a)===can be read in article used above and called Identical.$a === $bTRUEif$ais equal to$b, and they are of the same type.