-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
272 lines (174 loc) · 5.57 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php include("variables.php"); ?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<?php include("navbar.php"); ?>
<br/>
<center>
<h1>
<?php
// Print out to the screen
echo "Hello World!<br/>";
$first_name = "Austin";
$favorite_number = 12;
echo $first_name;
echo "<br/>";
//Math Operators
// + - * / % **
$num1 = 41;
$num2 = 4;
echo $num1 + $num2;
echo "<br/>";
//Increment
$num3 = 50;
echo ++$num3;
echo "<br/>";
//Important to note where you but the increment mark, below you will see it changes the value of $num4 after it posts. This is because the placement of -- is behind the $num4
$num4 = 50;
echo $num4--;
echo " ";
echo $num4;
echo "<br/>";
//Concantenation
$first_name1 = "John";
$last_name1 = "Elder";
echo $first_name1 . " " . $last_name1;
echo "<br/>";
//Comparison Operators
/* == Equal to
!= Not Equal to
> Greater Than
< Less Than
>= Greater Than or Equal to
<= Less Than or Equal To
*/
$num_1 = 41;
$num_2 = 4;
var_dump($num_1 == $num_2);
echo "<br/>";
//Escape Characters
echo "And then she said: \"YOU'RE UGLY!\"";
echo "<br/>";
//If Else Statements
$first_name2 = "Bob";
if ($first_name2 == "Austin") {
echo "Hello Austin! How are you?";
} else {
echo "You're not Austin! Who are you?";
}
echo "<br/>";
//Elseif Statements
$num_A = 40;
$num_B = 2;
if ($num_A > 100) {
echo $num_A . " is greater than 10";
} elseif ($num_B == 5) {
echo $num_B . " equals 5!";
} else {
echo $num_A . " is less than 100";
}
echo "<br/>";
//Numeric Arrays
$last_names = array("Elder", "Smith", "Poppins");
$first_names = array("John", "Steve", 40, $last_names);
echo ++$first_names[2];
echo "<br/>";
echo $first_names[3][0];
echo "<br/>";
//Associative Arrays
//Instead of using the number placement like above, we call the name of the person below (key) and the action returns Pepperoni (value). Key value pairs.
$fav_pizza = array(
"John"=>"Pepperoni",
"Steve"=>"Cheese",
"Mary"=>"Mushroom"
);
echo $fav_pizza["John"];
echo "<br/>";
//Array Count
$fav_pizza = array(
"John"=>"Pepperoni",
"Steve"=>"Cheese",
"Mary"=>"Mushroom"
);
echo count($fav_pizza);
echo "<br/>";
$names = array("John", "Steve", "Mary");
echo count($names);
echo "<br/>";
//If you don't know what the last item in the array is because you don't know how many items are in the array
echo $names[count($names) - 1];
echo "<br/>";
//Loops -- While
$counter = 0;
while ($counter <= 10){
echo "The count is: $counter<br/>";
++$counter;
}
echo "<br/>";
//Loops -- For
for ($counterA = 0; $counterA <= 10; $counterA++){
echo "The count is $counterA <br/>";
}
echo "<br/>";
//Loops -- Foreach
$namesC = array("John", "Steve", "Mary");
foreach ($namesC as $value){
echo "$value<br/>";
}
echo "<br/>";
//Functions
function helloThere($factorX, $factorY) {
return $factorX + $factorY;
}
$answer = helloThere(49, 1);
echo $answer * 1.1;
echo "<br/>";
//Random Function
rand(0,100);
//little bit better function for random numbers
mt_rand(0,10);
$things = array("John", "Steve", "Mary");
$rando = mt_rand (0,2);
echo $things[$rando];
echo "<br/>";
//Date Function - find the parameters on php.net function list
$todays_day = date('l jS \of F, Y');
echo "Today is $todays_day";
echo "<br/>";
//String Manipulation Functions
$stuff = "Austin is a php coding monster";
$monster = "monster";
$dork = "weirdo";
//The first posiition is the current or old value, the second position is the new value you want, the last position is the variable we are making changes to
echo str_replace("$monster", "$dork", $stuff);
echo "<br/>";
echo strtoupper($stuff);
echo "<br/>";
echo ucwords($stuff);
echo "<br/>";
echo strlen($stuff);
echo "<br/>";
//Include function
//see doc footer.php
include("footer.php");
?>
</h1>
</center>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
-->
</body>
</html>