Section 3 Sp 11
From CSE190M-Admin
[edit] Links
- Spec
- New section 3 handout (in development; contains additional smaller problems!)
- Solution to Buggy Code part:
- bug1.php
- line 20: missing '(' after 'if'
- line 22: missing '?>' tag to exit out of PHP mode
- line 30: missing '<?php' tag to enter PHP mode
- line 30: ' should be " to close string "David"
- bug2.php
- line 21: 'elif' should be 'elseif'
- line 21: '=' should be '=='
- line 33: shouldn't have 'int' before '$i'
- line 33: shouldn't have '$' before '10'
- line 34: use '.' not '+' for string concatenation
- (or better yet, just include the variable $i directly in the string with no .)
- bug3.php
- line 20: prices and price are backwards
- line 34: total_price keeps being reassigned
- bug4.php
- line 17: array declaration in parenthesis
- line 20: lots of problems, if your images are local, the src="(shouldn't not have a slash here), they are jpg files, var should be image, and embeded php needs an = sign.
- bug1.php
- Solution to 12 Days part:
.
[edit] Rough Outline
- Show them the linked lecture slides and teach them basic PHP syntax stuff, answer any questions they have. (~20-25 mins)
- Spend time on the buggy code. If they seem to pick up on it fast, feel free to move on. (~10-15 minutes)
- Be sure to show them how to debug, features of the xdebug installed on webster as well as going over the debug tips on the hand out
- Show them how to add debug prints, have some code uploaded / ready to live debug with them
- Try to write some/all of the 12 Days page.
- Probably won't finish; that's okay.
- This quarter we won't have had time to teach them the PHP expression blocks (where you insert an expression into HTML code rather than printing it). So you will have to write temporarily icky code such as:
- print "<p class=\"message\">Hello there</p>\n";
- Point out the steps/pics outlined; get them thinking about the problem one step (loop?) at a time.