Promenljive su kontejneri podataka.
Primer: prodajete motore preko Weba i zelite da proverite ukupne zalihe u sva tri magacina, koji se nalaze u Beogradu, Samoboru i Ljubljani. Da bi ste to postigli, morate da zajedno ubacite tri posebne vrednosti.
<?php
$beograd = 1;
$samobor = 2;
$ljubljana = 3;
echo "Ja imam " , $beograd + $samobor + $ljubljana , " motora";
//R: Ja imam 6 motora
?>
Rezultat
Primer dodavanja/povecanja vrednosti
$motor = 1;
echo "Broj motora: $motor <br>";
Recimo da sada hocete da povecate broj motora za 3. To ce te uraditi tako sto ce te vrednosti $motor dodeliti trenutnu vrednost $motor, uvecanu za 3.
Napomena: prethodni kod stavite pod komentar, tako da vam samo ostanu php tagovi.
echo "Dodavanje jos tri motora <br>";
$motor = $motor + 3 ;
echo "Broj motora sada: ", $motor, "<br>";
//R: Broj motora: 1
// Dodavanje jos tri motora
// Broj motora sada: 4
Rezultat
Variables are data containers.
For example, you are selling engines on the Web and want to check the total stock in all three warehouses, located in Belgrade, Ljubljana and Samobor. To do that, you have to insert together three separate values.
<? php
$beograd = 1;
$samobor = 2;
$ljubljana = 3;
echo "I have", $beograd + $samobor + $ljubljana, "motobikes";
// R: I have 6 motobikes
?>
An example of adding / increasing value
$motobike = 1;
echo "Number of motobikes: $motobike <br>";
Suppose you now want to maximize the number of engines for 3. You will get that by, to a $motobike you will assign the current value of $motobike, enlarged for 3.
Note: previous code place in comment, so you just have php tags.
echo "Adding three more motobikes <br>";
$motobike = $motobike + 3;
echo "The number of engines now", $motobike, "<br>";
// R: Number of motobikes: 1
// R: Adding three more motobikes
// R: Number of motobikes now: 4
Primer: prodajete motore preko Weba i zelite da proverite ukupne zalihe u sva tri magacina, koji se nalaze u Beogradu, Samoboru i Ljubljani. Da bi ste to postigli, morate da zajedno ubacite tri posebne vrednosti.
<?php
$beograd = 1;
$samobor = 2;
$ljubljana = 3;
echo "Ja imam " , $beograd + $samobor + $ljubljana , " motora";
//R: Ja imam 6 motora
?>
Rezultat
$motor = 1;
echo "Broj motora: $motor <br>";
Recimo da sada hocete da povecate broj motora za 3. To ce te uraditi tako sto ce te vrednosti $motor dodeliti trenutnu vrednost $motor, uvecanu za 3.
Napomena: prethodni kod stavite pod komentar, tako da vam samo ostanu php tagovi.
echo "Dodavanje jos tri motora <br>";
$motor = $motor + 3 ;
echo "Broj motora sada: ", $motor, "<br>";
//R: Broj motora: 1
// Dodavanje jos tri motora
// Broj motora sada: 4
Rezultat
Variables are data containers.
For example, you are selling engines on the Web and want to check the total stock in all three warehouses, located in Belgrade, Ljubljana and Samobor. To do that, you have to insert together three separate values.
<? php
$beograd = 1;
$samobor = 2;
$ljubljana = 3;
echo "I have", $beograd + $samobor + $ljubljana, "motobikes";
// R: I have 6 motobikes
?>
An example of adding / increasing value
$motobike = 1;
echo "Number of motobikes: $motobike <br>";
Suppose you now want to maximize the number of engines for 3. You will get that by, to a $motobike you will assign the current value of $motobike, enlarged for 3.
Note: previous code place in comment, so you just have php tags.
echo "Adding three more motobikes <br>";
$motobike = $motobike + 3;
echo "The number of engines now", $motobike, "<br>";
// R: Number of motobikes: 1
// R: Adding three more motobikes
// R: Number of motobikes now: 4
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.