Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
dvprog_02 [2018-08-24 12:42] Daniel Viström |
dvprog_02 [2020-08-26 16:57] Daniel Viström |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Genomgång | + | ====== Genomgång - Inledning php ====== |
<php> | <php> | ||
Line 36: | Line 36: | ||
echo '< | echo '< | ||
echo '< | echo '< | ||
- | $name1 = '4Bertil'; | + | $name1 = 'Bertil'; |
- | $name2 = '3Stina'; | + | $name2 = 'Stina'; |
$tal1 = 5; // integer (heltal) | $tal1 = 5; // integer (heltal) | ||
$tal2 = 7; | $tal2 = 7; | ||
- | echo $name1; | + | echo $name1; |
- | echo '< | + | |
- | echo $name1 + $name2; | + | |
- | echo '< | + | |
- | echo $name1 . $name2; | + | |
echo '< | echo '< | ||
+ | echo $name1 . ' & ' . $name2 . '< | ||
- | echo $name1 . $name2 . '< | + | $tal1 + $tal2; // Datorn beräknar men skriver inte ut något. |
- | echo 'Hej hej< | + | echo $tal1 + $tal2 . '< |
- | + | $tal3 = $tal1 + $tal2; | |
- | $tal3 = $tal1 + $tal2; // skapar ny variabel innehållande ett heltal som blir summan av de två talen. | + | |
- | echo $tal3; | + | |
- | echo '< | + | |
- | $tal3 = $tal1 . $tal2; | + | |
echo $tal3 . '< | echo $tal3 . '< | ||
+ | $tal3 = $tal1 . $tal2; | ||
+ | echo $tal3 . '< | ||
+ | echo ' | ||
- | echo ' | ||
- | | ||
$tal4 = $tal3 / $tal2; | $tal4 = $tal3 / $tal2; | ||
echo $tal4 . '< | echo $tal4 . '< | ||
echo (int) $tal4 . '< | echo (int) $tal4 . '< | ||
- | $tal4 = (int) $tal4; | + | echo $tal4 . '< |
- | echo $tal4 . '< | + | $tal4 = (int) $tal4; |
+ | echo $tal4 . '< | ||
| | ||
Line 82: | Line 77: | ||
// && betyder " | // && betyder " | ||
if ($name1 == ' | if ($name1 == ' | ||
- | echo 'Nu skrivs det ut 1< | + | echo 'Båda villkoren är sanna.< |
} | } | ||
// || betyder " | // || betyder " | ||
if ($tal1 == 5 || $tal2 <2) { | if ($tal1 == 5 || $tal2 <2) { | ||
- | echo 'Nu skrivs det ut 2< | + | echo 'Minst ena villkoret är sant.< |
} | } | ||
| | ||
// ! betyder " | // ! betyder " | ||
- | if (!($tal1 == 6)){ | + | if (!($tal1 == 6)){ // Blir samma som: if ($tal1 != 6){ |
- | echo 'Nu skrivs det ut 3< | + | echo 'Talet är inte 6< |
} | } | ||