File tree 4 files changed +127
-0
lines changed
tutorial-006-conditional-statements
4 files changed +127
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ echo '
3
+ <!DOCTYPE html>
4
+ <html>
5
+ <head></head>
6
+ <body>
7
+ ' ;
8
+
9
+ $ moneyIHave = 0 ;
10
+ $ burgerPrice = 10 ;
11
+ $ sandwichPrice = 5 ;
12
+ $ hotdogPrice = 1 ;
13
+
14
+ // ✅ > 10 -> burger
15
+ // ✅ > 5 -> sandwich
16
+ // ✅ > 1 -> hotdog
17
+ // ✅ other cases -> go hunting
18
+
19
+ if ($ moneyIHave > $ burgerPrice ) {
20
+ echo '
21
+ I will buy and eat a burger🍔<br>
22
+ I will drink my soda🥤<br>
23
+ I will enjoy my fries🍟<br>
24
+ ' ;
25
+ } elseif ($ moneyIHave > $ sandwichPrice ) {
26
+ echo '
27
+ Buy and eat a sandwich🥪<br>
28
+ ' ;
29
+ } elseif ($ moneyIHave > $ hotdogPrice ) {
30
+ echo '
31
+ Buy and eat a hotdog🌭<br>
32
+ ' ;
33
+ } else {
34
+ echo '
35
+ Go hunting🏹🦌<br>
36
+ Cook a meal🏕️🔥<br>
37
+ Eat that meal🍖<br>
38
+ ' ;
39
+ }
40
+
41
+ echo 'I want to have fun! ' ;
42
+
43
+ echo '
44
+ </body>
45
+ </html>
46
+ ' ;
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <?php
6
+
7
+ $ moneyIHave = 2 ;
8
+ $ burgerPrice = 10 ;
9
+ $ sandwichPrice = 5 ;
10
+ $ hotdogPrice = 1 ;
11
+
12
+ // ✅ > 10 -> burger
13
+ // ✅ > 5 -> sandwich
14
+ // ✅ > 1 -> hotdog
15
+ // ✅ other cases -> go hunting
16
+
17
+ if ($ moneyIHave > $ burgerPrice ) {
18
+ ?>
19
+ I will buy and eat a burger🍔<br>
20
+ I will drink my soda🥤<br>
21
+ I will enjoy my fries🍟<br>
22
+ <?php
23
+ } elseif ($ moneyIHave > $ sandwichPrice ) {
24
+ ?>
25
+ Buy and eat a sandwich🥪<br>
26
+ <?php
27
+ } elseif ($ moneyIHave > $ hotdogPrice ) {
28
+ ?>
29
+ Buy and eat a hotdog🌭<br>
30
+ <?php
31
+ } else {
32
+ ?>
33
+ Go hunting🏹🦌<br>
34
+ Cook a meal🏕️🔥<br>
35
+ Eat that meal🍖<br>
36
+ <?php
37
+ }
38
+
39
+ echo 'I want to have fun! ' ;
40
+
41
+ ?>
42
+
43
+ </body>
44
+ </html>
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ if (50 > 10 )
4
+ {
5
+ echo 'I will buy and eat a burger🍔<br> ' ;
6
+ echo 'I will drink my soda🥤<br> ' ;
7
+ echo 'I will enjoy my fries🍟<br> ' ;
8
+ }
9
+
10
+ echo 'I want to have fun! ' ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ $ moneyIHave = 50 ;
4
+ $ burgerPrice = 10 ;
5
+ $ sandwichPrice = 5 ;
6
+ $ hotdogPrice = 1 ;
7
+
8
+ // ✅ > 10 -> burger
9
+ // ✅ > 5 -> sandwich
10
+ // ✅ > 1 -> hotdog
11
+ // ✅ other cases -> go hunting
12
+
13
+ if ($ moneyIHave > $ burgerPrice ) {
14
+ echo 'I will buy and eat a burger🍔<br> ' ;
15
+ echo 'I will drink my soda🥤<br> ' ;
16
+ echo 'I will enjoy my fries🍟<br> ' ;
17
+ } elseif ($ moneyIHave > $ sandwichPrice ) {
18
+ echo 'Buy and eat a sandwich🥪<br> ' ;
19
+ } elseif ($ moneyIHave > $ hotdogPrice ) {
20
+ echo 'Buy and eat a hotdog🌭<br> ' ;
21
+ } else {
22
+ echo 'Go hunting🏹🦌<br> ' ;
23
+ echo 'Cook a meal🏕️🔥<br> ' ;
24
+ echo 'Eat that meal🍖<br> ' ;
25
+ }
26
+
27
+ echo 'I want to have fun! ' ;
You can’t perform that action at this time.
0 commit comments