If else condition in php


If you have a code block like the following:

	$variable = $value1
} else {
	$variable = $value2

It is possible to shorten it to the following:

$variable = (statement)?$value1:$value2;

The above line of code is for PHP. Below is the same for JavaScript, where only the syntax is different.

var variable = (statement)?value1:value2;



Bjarne Bonde