lecture1 - cdn.cs75.netcdn.cs75.net/2011/summer/lectures/1/lecture1.pdf · Title: lecture1.ppt...

Post on 07-Oct-2020

2 views 0 download

Transcript of lecture1 - cdn.cs75.netcdn.cs75.net/2011/summer/lectures/1/lecture1.pdf · Title: lecture1.ppt...

0

Computer Science S-75 Building Dynamic Websites Harvard Summer School

http://www.cs75.net/

Lecture 1: PHP

David J. Malan

dmalan@harvard.edu

1

HTTP

Images from howstutfworks.com.

2

Apache

Images from apache.org.

http://httpd.apache.org/docs/2.2/

3

Apache # www.cs75.net <VirtualHost *:80> CustomLog logs/www.cs75.net-access_log common DocumentRoot /home/cscie75/srv/www/www.cs75.net/html ErrorLog logs/www.cs75.net-error_log ServerAdmin help@cs75.net ServerAlias cs75.net ServerName www.cs75.net </VirtualHost> <VirtualHost *:443> CustomLog logs/www.cs75.net-access_log common DocumentRoot /path/to/htdocs ErrorLog logs/www.cs75.net-error_log ServerAdmin dmalan@harvard.edu ServerAlias cs75.net ServerName www.cs75.net SSLCertificateChainFile /path/to/gd_bundle.crt SSLCertificateFile /path/to/cs75.crt SSLCertificateKeyFile /path/to/cs75.key SSLEngine on </VirtualHost>

4

mod_rewrite RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.cs75\.net [NC] RewriteRule (.*) https://www.cs75.net/$1 [R=301,L]

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

5

XAMPP

  Linux, Mac OS, Solaris, Windows   Apache   MySQL   PHP   Perl

Image from pplware.com.

6

VirtualBox

Image from wikipedia.org.

7

Forms   Text Fields

<input name="email" type="text" />

  Password Fields <input name="password" type="password" />

  Hidden Fields <input name="id" value="123" />

  Checkboxes <input checked="checked" name=“remember" type="checkbox" />

  Radio Buttons <input name="gender" type="radio" value="F" /> <input name="gender" type="radio" value="M" />

  Drop-Down Menus <select name=“state"> <option value=""></option> <option value=“MA"></option> <option value=“NY"></option> </select>

  Text Areas

<textarea name=“comments"></textarea>

8

Forms

9

PHP

http://us3.php.net/manual/en/

Image from php.net.

10

suPHP

http://www.suphp.org/

Image from suphp.org.

11

<?php

http://us2.php.net/manual/en/langref.php

12

Variables

“A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.”

Excepted from http://us2.php.net/manual/en/language.variables.php.

13

Types   boolean   integer   float   string

  array   object

  resource   NULL

  mixed   number   callback

14

References

http://us2.php.net/manual/en/language.references.php

15

Superglobals

  $_COOKIE   $_ENV   $_FILES   $_GET   $_POST   $_REQUEST   $_SERVER   $_SESSION

16

Arrays

http://us2.php.net/array

17

Loops

  for   while   do ... while   foreach

18

Computer Science S-75 Building Dynamic Websites Harvard Summer School

http://www.cs75.net/

Lecture 1: PHP

David J. Malan

dmalan@harvard.edu