Operator perbandingan pada struktur control program seperti if, elseif dimana dilakukan perbandingan dua nilai.
Assume: $x = 4 and $y = 5;
Contoh penulisan dalam PHP
<?php // nama file : operator_perbandingan.php $x = 4; $y = 5; echo "<br>Nilai \$x = $x"; echo "<br>Nilai \$y = $y"; $val = ($x == $y) ? "TRUE" : "FALSE"; echo "<br>Operator perbandingan \$x == \$y = $val"; $val = ($x != $y) ? "TRUE" : "FALSE"; echo "<br>Operator perbandingan \$x != \$y = $val"; $val = ($x < $y) ? "TRUE" : "FALSE"; echo "<br>Operator perbandingan \$x < \$y = $val"; $val = ($x > $y) ? "TRUE" : "FALSE"; echo "<br>Operator perbandingan \$x > \$y = $val"; $val = ($x <= $y) ? "TRUE" : "FALSE"; echo "<br>Operator perbandingan \$x <= \$y = $val"; $val = ($x >= $y) ? "TRUE" : "FALSE"; echo "<br>Operator perbandingan \$x >= \$y = $val"; ?>
Selamat Mencoba, Semoga Bermanfaat :')
0 Komentar untuk " Operator Pembanding Dalam PHP "