Website Development Prices

Search Blog

Saturday, October 10, 2015

Operatori poredjenja deo 2 (Comparison operators part 2)

Sa iskazom if se koristi citav niz operatora. To su operatori poredjenja. Oni omogucavaju da se porede dve vrednosti. 

U prethodnom clanku su dati svi operatori poredjenja koji postoje u PHP-u.

Ako zelite da proverite da li je vrednost promenljive $temperatura bila tacno 65 stepeni, mozete upotrebiti operator jednokosti ==.

Primer:

<?php

$temperatura = 65;

if ($temperatura == 65) {
echo "Danas je 65 stepeni.";
}

?>

Ovaj fajl sacuvajte kao operatori-poredjenja.sql.

Rezultat: Danas je 65 stepeni.


Primer 2: ako koristite operator razlicito!=, koji vraca tacno, ako dve vrednosti nisu jednake. Proveravamo da li je temperatura bila 65 stepeni.

$temperatura = 70;

if ($temperatura != 65) {
echo "Danas nije 65 stepeni.";
}

Rezultat: Danas je 65 stepeni.

With the if statement is used a range of operators. These are the comparison operators. They make it possible to compare two values.

In the previous article are given all the comparison operators that exist in PHP.

If you want to make sure that the value of $temperature was exactly 65 degrees, you can use the equality operator ==.

Example:

<? php

$temperature = 65;

if ($temperature == 65) {
echo "Today is 65 degrees.";
}

?>

Save this file as comparison-operators.sql.

The result: Today is 65 degrees.

Example 2: if you use a operator different!=, which returns true if the two values are not equal. We will verify whether the temperature was 65 degrees.

$temperature = 70;

if ($temperature != 65) {
echo "Today is not 65 degrees.";
}

The result: Today is not 65 degrees.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.