Lecture 3 -Arrays, loops, functions - annotated

Lecture 3 -Arrays, loops, functions - annotated - Tech...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Tech Talk: Getting into the Mind of the User Tuesday, 1/29 at 4:30PM Olin 255 Hosted by Laura Granka, Google Researcher Refreshments will be served. Résumés will be accepted. PHP: Arrays, loops, functions INFO/COM S 230: Intermediate Web Design and Programming Running PHP Unlike XHTML, PHP must run off server Testing your PHP code Upload to info230 server and look at it there via web browser http://info230.cs.cornel .edu/users/ username /www/ filename Installing a webserver and PHP on your machine Some other more user friendly servers, but Apache the standard Beware security issues! Will run through an installation in an upcoming section Arrays Easy PDF Creator is professional software to create PDF. If you wish to remove this line, buy it now.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Arrays Arrays let us keep track of lists of information. E.g. Programming languages David knows: • C • Java • PHP Making an array Write as $languages = array(“C”, “Java”, “PHP”); Items in array can be accessed by their index. $language[0] is the first element in the array. $language[1] is the second element. $language[2] is the third element… What happens? print(“$languages[2], $languages[0], $languages[1]”); Modifying arrays To change a value of an element: $languages[2] = “PHP 4”; To add another element at the end of the array: $languages[ ] = “Cobol”; Enumerating arrays You can use “foreach” if you want to do something for each element in the array. E.g. print(“You know the languages ”); foreach ($languages as $lang) { print(“$lang,”); } One more form type: Checkboxes What computer languages do you know ? <input type="checkbox" name="langs[]" value="C" /> C
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2008 for the course INFO 2300 taught by Professor Williamson during the Spring '08 term at Cornell University (Engineering School).

Page1 / 6

Lecture 3 -Arrays, loops, functions - annotated - Tech...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online