Operator ternar în php

Exemple de cod

10
0

Operator ternar php

(Condition) ? (Statement1) : (Statement2);
5
0

operator ternar în php

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

ternar php

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

php ternar

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

ternary în php

print ($marks>=40) ? "pass" : "Fail";
1
0

operatori ternari php

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

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

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

?? operatorul ternar în php

echo $color = $color ?? 'red';	//if value not exists then assign to them.
0
0

operatorul ternar pentru trei condiții în php

$foo = your_value;
$bar = ($foo == 1) ? "1" : (($foo == 2)  ? "2" : "other");
echo $bar;
0
0

operatorul ternar în php

<?php
  $x=4;
  $y=3;
  if(x>y)?echo"X is large": echo "y is large";

 ?>

În alte limbi

Această pagină este în alte limbi

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