Pokud jinak ternární operátor php

Příklady kódu

5
0

php ternární operátor

<?php 
#Syntex  
(if Condition) ? (stat1) : (stat2);

#example
$var1 = 5;
$var2 = 2;

echo $check = ($var1 > $var2) ? "right" : "wrong";

#output : right
/*
explination : if condition is true then display the stat1 and if condition is 
worng then display stat2
*/
?>
5
0

ternární operátor v php

<?php
$marks=40;
print ($marks>=40) ? "pass" : "Fail";
?>
3
0

php ternární

$result = $condition ? 'foo' : 'bar';
2
0

php ternární zkratka

$y = $x ? "true" : "false";
1
0

php ternární operátoři

// Both ternary and if/else returns the same result

// ternary
$result = $condition ? 'foo' : 'bar';

// if/else
if ($condition) {
    $result = 'foo' 
} else {
    $result = 'bar'
}

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................