note 9441 added to Operator Precedence

From: Date: Fri, 03 Nov 2000 02:21:09 +0000
Subject: note 9441 added to Operator Precedence
Groups: php.notes 
Request: Send a blank email to php-notes+get-7314@lists.php.net to get a copy of this message
The ternary functional conditional operator (?:) is listed in the precedence chart, but doesn't seem to be defined anywhere in the operator documentation. It's familiar from C and related languages, but since some people are learning PHP as their first language, it is well to define it here. foo ? bar : baz will return bar if foo is true, and baz if foo is false. In other words, it's like an "if..else" statement inside an expression. For example: echo "Your number is ", ($x>4)? "too big" : "just right"; http://www.php.net/manual/language.operators.precedence.php

« previous php.notes (#7314) next »