PHP shorthand if else

preview_player
Показать описание
$var = ($condition) ? true : false;

also works in javascript but the entire guy has to be wrapped in parenthesis
Рекомендации по теме
Комментарии
Автор

here is the JavaScript version

var ampm = (h<12) ? "am" : "pm";

optikalefx
Автор

@Timzy921
Its really called "trinary operator" not a "shorthand if statement"
google it and you will see a site called Added Bytes that also has a details about it.

carnagerpm
Автор

Thank Optikalefx you taught very nice way :)

manishgoswami
Автор

thanks... i love understandble explenations ;)

SagiveCoIl