forked from b2much/gdi-intro-php-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class1.html
478 lines (442 loc) · 19.5 KB
/
class1.html
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<!doctype html>
<html lang="en">
<head>
<title>Class 1 ~ PHP/MySQL ~ Girl Develop It</title>
<meta name="description" content="This is a modification of the official Girl Develop It PHP/MySQL curriculum, developed by Sylvia Richardson for the Raleigh/Durham chapter.
The course is meant to be taught in 4 two-hour sections. Each of the slides and practice files are customizable according to the needs of a given class or audience.">
<meta name="author" content="Girl Develop It">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/simple.css" id="theme">
<link rel="stylesheet" href="css/custom.css">
<!-- For syntax highlighting -->
<!-- light editor<link rel="stylesheet" href="lib/css/light.css">-->
<!-- dark editor--><link rel="stylesheet" href="lib/css/dark.css">
<link rel="stylesheet" href="lib/css/zenburn.css">
<link rel="stylesheet" href="plugin/accessibility-helper/css/accessibility-helper.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!-- If use the PDF print sheet so students can print slides-->
<link rel="stylesheet" href="css/print/pdf.css" type="text/css" media="print">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<!-- Opening slide -->
<section>
<section>
<img src="img/circle-gdi-logo.png" alt="GDI Logo" class="noborder" style="max-height:400px;">
<h3>Intro to PHP and MySQL</h3>
<h4>Class 1</h4>
</section>
</section>
<!-- Welcome-->
<section id="welcome">
<section>
<h3>Welcome!</h3>
<div class = "left-align">
<p>Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.</p>
<p class ="green">Some "rules"</p>
<ul>
<li>We are here for you!</li>
<li>Every question is important.</li>
<li>Help each other.</li>
<li>Have fun.</li>
</ul>
</div>
</section>
<section>
<h3>Welcome!</h3>
<div class = "left-align">
<p class = "blue">Tell us about yourself.</p>
<ul>
<li>Who are you?</li>
<li>What do you hope to get out of the class?</li>
<li>What is your favorite 80's song?</li>
</ul>
</div>
</section>
</section>
<!-- Install -->
<section id="install">
<section>
<h3>Let's Develop It</h3>
<p>Let's get PHP running on your machine.<p>
<p>PCs: <a href="http://www.wampserver.com/en/download.php">http://www.wampserver.com/en/download.php</a></p>
<p>Macs: <a href="http://www.mamp.info/en/downloads/index.html">http://www.mamp.info/en/downloads/index.html</a></p>
<p>Test: <a href="http://localhost/">http://localhost/</a>
</section>
<section>
<h3>Let's Develop It</h3>
<p>Make your first page! Find your www directory. On Windows, the default is C:\wamp\www. On a Mac, it is \Applications\MAMP\htdocs\. Create a new folder, called gdi, and then create a file inside called index.php.</p>
<pre><code class="html"><!DOCTYPE html>
<html>
<head>
<title>Test Page</title>
</head>
<body>
<p>
<?php
echo 'Hello World';
?>
</p>
</body>
</html>
</code></pre>
</section>
</section>
<!-- What is PHP-->
<section id="whatis">
<section>
<h3>PHP is a server-side language</h3>
<img src="img/client-server.jpg" alt="Laptop and server connected via the internet"/>
<p><small>Photo credits: <a href="http://www.flickr.com/photos/papalars/5210226441/" target="_blank">Andrew E. Larson</a> and <a href="http://www.flickr.com/photos/johnseb/3425464/" target="_blank">John Seb Barber</a> <a href="http://creativecommons.org/licenses/by-nc/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>PHP can talk to databases</h3>
<img src="img/elephants.jpg" alt="Two elephants interacting"/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/ginable/325235488/">Ginable</a> <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">cc</a></small></p>
</section>
<section>
<h3>PHP lets you reuse code</h3>
<img src="img/desert-landscape.jpg" alt="Desert landscape"/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/philsnyder/4216356826/" target="_blank">Phil Synder</a> <a href="http://creativecommons.org/licenses/by-nc/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>What is PHP?</h3>
<ul>
<li>Originally, PHP stood for Personal Home Page. The acronym doesn't mean much anymore, but officially it is called PHP: Hypertext Processor</li>
<li>PHP is a server-side processing language. The server reads the PHP code and outputs browser-friendly HTML</li>
<li>PHP has simple support for databases like MySQL.</li>
<li>With PHP, you can write code once and use it everywhere. Remember, you want DRY code (Don't Repeat Yourself).</li>
<li>PHP lets you build dynamic webpages that respond to input from users.</li>
</ul>
</section>
</section>
<!-- Basics -->
<section id="basics">
<section>
<h3>Computers need simple, clear instructions</h3>
<img src="img/confusedrobot.jpg" alt="Confused robot"/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/baboon/3946055/" target="_blank">baboon</a> <a href="http://creativecommons.org/licenses/by-nc/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>PHP Tags</h3>
<p>You can mix PHP and HTML. When a PHP server looks at a page, it only pays attention to code within the PHP tags.</p>
<pre><code class="html"><?php CODE GOES HERE ?>
</code></pre>
</section>
<section>
<h3>Separating Instructions</h3>
<p>After each individual statement, you must add a semicolon.</p>
<pre><code class="php">echo 'Hello World!';
echo 'I am glad to meet you';
echo 'I am fuzzy';
</code></pre>
</section>
<section>
<h3>Comments</h3>
<p>You can leave comments in your code—notes that people can read and computers will ignore.</p>
<pre><code class="php">/*I can wrap long comments
with multiple lines
like this*/
echo 'Hello World!'; //Or mark short comments like this
</code></pre>
</section>
</section>
<!-- Variables -->
<section>
<section>
<h3>Variables</h3>
<p>A variable is a place to store values</p>
<img src="img/empty-glass.jpg" alt="Empty glass"/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/giuliag/3570562404/" target="_blank">giulia gasparro</a> <a href="http://creativecommons.org/licenses/by-nc/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>Variable Values</h3>
<ul>
<li>When you first create a variable, it does not have a value (it is null).</li>
<li>You can set a value for a variable.</li>
<li>Variables can hold different types of information, like words, numbers, and collections of data.</li>
<li>The value of a variable can change over time.</li>
</ul>
</section>
<section>
<h3>Naming Variables</h3>
<ul>
<li>In PHP, you write a variable with a dollar sign followed by the name of the variable.</li>
<li>The variable name is case-sensitive.</li>
<li>A new variable needs to have a unique name.</li>
<li>Variable names need to start with a letter or underscore.</li>
<li>Variable names can only be made of letters and numbers.</li>
</ul>
</section>
<section>
<h3>Creating a Variable</h3>
<p>To create a variable, just type a dollar sign and the variable name. PHP will create the variable for you.</p>
<pre><code class="php">$numberOfKittens;
</code></pre>
<p>It is a good idea to give your variable a starting value. This is called initializing the variable.</p>
<pre><code class="php">$numberOfKittens = 5;
</code></pre>
</section>
<section>
<h3>Using a Variable</h3>
<p>Once you have created a variable, you can use it in your code. Just type a dollar sign and the name of the variable</p>
<pre><code class="php">$numberOfKittens = 5;
echo $numberOfKittens;
</code></pre>
</section>
<section>
<h3>Let's Develop It</h3>
<p>In your PHP file, create a variable and give it a valid name and a value. Then, echo it out on the screen.</p>
</section>
</section>
<!-- Variable Types and Operators-->
<!-- Numbers-->
<section>
<section>
<h3>Numbers!</h3>
<img src="img/kitten-basket.jpg" alt="Cat jumping on another cat."/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/tom-poes/2159348460/" target="_blank">WJ van den Eijkhof</a> <a href="http://creativecommons.org/licenses/by-nc/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>Numbers</h3>
<p>Variable can be numbers, either integers or floats (decimals).</p>
<pre><code class="php">$numberOfKittens = 5;
$cutenessRating = 9.6;
</code></pre>
<p>PHP will automatically convert integers to floats if needed</p>
</section>
<section>
<h3>Arithmetic Operators</h3>
<p>Once you have numbers, you can do math with them!</p>
<pre><code class="php">$numberOfKittens = 5;
$numberOfPuppies = 4;
$numberOfAnimals = $numberOfKittens + $numberOfPuppies;
</code></pre>
</section>
<section>
<h3>Arithmetic Operators</h3>
<table>
<thead>
<tr>
<th>Example</th>
<th>Name</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td>-$a</td>
<td>Negation</td>
<td>Opposite of $a.</td>
</tr>
<tr>
<td>$a + $b</td>
<td>Addition</td>
<td>Sum of $a and $b.</td>
</tr>
<tr>
<td>$a - $b</td>
<td>Subtraction</td>
<td>Difference of $a and $b.</td>
</tr>
<tr>
<td>$a * $b</td>
<td>Multiplication</td>
<td>Product of $a and $b.</td>
</tr>
<tr>
<td>$a / $b</td>
<td>Division</td>
<td>Quotient of $a and $b.</td>
</tr>
<tr>
<td>$a % $b</td>
<td>Modulus</td>
<td>Remainder of $a divided by $b.</td>
</tr>
</tbody>
</table>
</section>
<section>
<h3>Let's Develop It</h3>
<p>Create two variables and try some arithmetic operators. Don't forget to echo your results!</p>
</section>
</section>
<!-- Strings -->
<section>
<section>
<h3>Strings</h3>
<p>Variable can be strings, groups of characters. You put your string in quotes.</p>
<pre><code class="php">$kittensName = 'Fluffy';
</code></pre>
<p>If you want to use a quote in your string, you'll need to "escape" it with a backslash.</p>
<pre><code class="php">echo 'I\'d like to use an apostrophe';
</code></pre>
</section>
<section>
<h3>Playing with Strings</h3>
<img src="img/kitten-string.jpg" alt="Cat playing with string"/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/dirtbikedba/5796961878/" target="_blank">Mike Lawson</a> <a href="http://creativecommons.org/licenses/by-nc/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>String Operators</h3>
<p>You can put strings together with a period, the concatenation operator.</p>
<pre><code class="php">$kittensName = 'Fluffy';
$fullName = $kittensName . ' McDougle';
echo $fullName; //Outputs 'Fluffy McDougle'
</code></pre>
</section>
<section>
<h3>String Operators</h3>
<p>You can also use .= to add things to the end of a string.</p>
<pre><code class="php">$kittensName = 'Admiral';
$kittensName .= ' Snuggles';
echo $kittensName; //Outputs 'Admiral Snuggles'
</code></pre>
</section>
<section>
<h3>Concatenate!</h3>
<img src="img/concatenate.jpg" alt="Cat jumping on another cat."/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/furlined/8191032061/" target="_blank">Matt</a> <a href="http://creativecommons.org/licenses/by-nc/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>Let's Develop It</h3>
<p>Create two variables, a first name and a last name, and then put them together to make a full name. Don't forget to echo your results!</p>
</section>
</section>
<!-- Functions -->
<section id="functions">
<section>
<h3>Functions</h3>
<p>Functions are separable, reusable pieces of code.
<img src="img/legos.jpg" alt="Pile of legos"/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/catzrule/9940388305/">Rick Payette</a> <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">cc</a></small></p>
</section>
<section>
<h3>Using Functions</h3>
<p>First, declare the function.</p>
<pre><code class="php">function turtleFact() {
echo 'A turtle\'s lower shell is called plastron.';
}
</code></pre>
<p>Then, use it as many times as you want!</p>
<pre><code class="php">turtleFact();
</code></pre>
</section>
<section>
<h3>Arguments</h3>
<p>Functions can accept input values, called arguments.</p>
<pre><code class="php">function callKitten ($kittenName){
echo 'Come here, ' . $kittenName . '!';
}
callKitten ('Fluffy'); //outputs 'Come here, Fluffy!'
function addNumbers($a, $b) {
echo $a + $b;
}
addNumbers(5,7); //outputs 12
addNumbers(9,12); //outputs 21
</code></pre>
</section>
<section>
<h3>Arguments</h3>
<p>You can also pass variables into functions. These variables do not need to have the same name as the function arguments.</p>
<pre><code class="php">function addOne($inputNumber){
$newNumber = $inputNumber + 1;
echo '<p>You now have ' . $newNumber . '</p>';
}
//Declare variables
$numberOfKittens = 5;
$numberOfPuppies = 4;
//Use them in functions
addOne($numberOfKittens);
addOne($numberOfPuppies);
</code></pre>
</section>
<section>
<h3>Let's Develop It</h3>
<p>Turn the code you wrote to output someone's full name into a function, then use it.</p>
</section>
</section>
<!-- Returning values -->
<section>
<section>
<h3>Returning Values</h3>
<p>You can have a function give you back a value, to use later.</p>
<pre><code class="php">function square($num) {
return $num * $num;
}
echo square(4); // outputs '16'.
$squareOfFive = square(5); // will make $squareOfFive equal 25.
</code></pre>
<p>Return will immediately end a function.</p>
</section>
<section>
<h3>Let's Develop It</h3>
<p>Add a return statement to your name function. Use that function to set the value of a variable.</p>
</section>
</section>
<!-- Final slides-->
<section id="final">
<section>
<h3>You did it!</h3>
<img src="img/celebration.jpg" alt="People celebrating"/>
<p><small>Photo credit: <a href="http://www.flickr.com/photos/morphomir/2407451929/" target="_blank">Mircea</a> <a href="http://creativecommons.org/licenses/by-sa/2.0/" target="_blank">cc</a></small></p>
</section>
<section>
<h3>Resources</h3>
<ul>
<li><a href="http://www.php.net/manual/en/" target="_blank">PHP Manual</a>, the official PHP documentation. Check the comments; they are useful.</li>
<li><a href="http://www.codecademy.com/tracks/php" target="_blank">Code Academy</a>, with interactive PHP lessons to help you review.</li>
</ul>
</section>
</section>
</div>
<footer>
<div class="copyright">
PHP/MySQL ~ Girl Develop It
<a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/3.0/80x15.png" /></a>
</div>
</footer>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/accessibility-helper/js/accessibility-helper.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>