Skip to content

Lecture Notes - Week 1

Readings

  • Syllabus
  • Chapters:
    • Introduction
    • 1 - The Life and Times of a PHP Script
    • 2 - Writing Your First PHP Script (pgs. 15 - 19)

Screencast - Week 1

Outline of Topics

Lecture

What is Open Source?

'Free software' is a matter of liberty, not price. To understand the concept, you should think of 'free' as in 'free speech,' not as in 'free beer.' - The Free Software Foundation

  • What is the difference between Open Source and Freeware?
    Freeware is software that is free to use but you do not have access to the source of that application. Open Source means you have the ability to view and modify the code of the application. Ideally an open source project will accept modifications from the community.

  • Is PHP Open Source?

Static vs. Dynamic Web Sites

  • A static web site is a page of content that is rendered the same every time it is requested.

  • A dynamic web site is one with content that is regenerated every time a user visits or reloads the site.

What is HTTP?

  • What does HTTP stand for?
    Hypertext Transfer Protocol

  • What does an HTTP Request look like?

http request response

What is PHP?

PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world. – php.net

  • History of PHP

    • June 8, 1995 PHP 1.0 is posted to the usenet group comp.infosystems.www.authoring.cgi.

    • It was created by Rasmus Lerdorf as PHP Tools.

    • Then he set to work integrating his tools with the Apache web server and less than a year later, PHP 2.0 was posted to the same usenet group.

    • PHP originally stood for: Personal Home Pages.

    • PHP now stands for: PHP Hypertext Preprocessor (a recursive acronym).

    • It is most likely the fastest and simplest tool available for creating database-enabled web sites.

    • It will work with any UNIX-based web server on every UNIX flavor out there. The package is completely free of charge for all uses including commercial.

Here is how Rasmus described PHP at the time:

PHP/FI is a server-side HTML embedded scripting language. It has built-in access logging and access restriction features and also support for embedded SQL queries to mSQL and/or Postgres95 backend databases.

What does a PHP script look like?

1
<?php phpinfo(); ?>

PHP Functions

An independent piece of program code that is created to make programing easier.

1
Today is <?php echo date("m-d-Y"); ?>

The above code uses PHPs date function. The documentation can be found at https://www.php.net/manual/en/function.date.php

PHP and HTML

Here is PHP and HTML integrated together:

1
2
3
4
5
6
7
8
<html>
  <head>
    <title>My Awesome Page</title>
  </head>
  <body>
      <h1>Today is <?php echo date("m-d-Y"); ?></h1>
  </body>
</html>

MySQL

  • The most popular open-source relational database

  • Here is what it looks like:

1
2
3
4
> SHOW databases;
> USE northwind;
> SHOW tables;
> SELECT * FROM test;
  • Why PHP & MySQL?

    • Both Open Source

    • Commonly used together

    • Both have a low barrier to entry

Debugging

  • Apache Log

Getting Help

Week 1 Lab