Sunday, August 12, 2007

Notes on PHP Programming, Part I.

( Photo Caption: The building where the UP Information Technology Training Center is located. Source: http://www.ittc.up.edu.ph/ )

Last Sunday, August 12, 2007 I attended a short course on "PHP&MySQL" at the University of the Philippines Information Technology Center (UPITTC) in Diliman, Quezon City. This course will run for four Sundays. This is the training course that I wanted to attend last August 5, 2007, the day that I had a car accident at the C-5 flyover in Pasig City (see blog entry, http://raffysaldana.blogspot.com/2007/08/do-you-know-what-to-do-after-car.html). I came all the way from Bacoor, Cavite to U.P. Diliman that day just to find out that the first meeting was cancelled (postponed to August 12, 2007).

Here are some of my notes on the first day of the course:

============================
UPITTC
PhP&MySQL Web Applications
Day 1: August 12, 2007

============================

9:00 - 9:45 a.m. Introduction

Instructor: Regnard Kreisler C. Raquedan

Participants:

Karla, Shanel, Jay, Michael, Che, Dennis
Raffy, Francis, Jarvis, Nino, Janet, Weng, Alain, Gold
Jun, Melody, Richard, VJohn, Roland, Albert, Apple, Jason

10:00 a.m.
Notes: CRUD project (Create, Read, Update, Delete)

Course Requirements:
Class project
Written exam (probable)
(short but tricky exam)
No project, no certificate of completion

Course Prerequisites:
1. WWW
2. HTML
3. General Programming Concepts
4. Basic Knowledge of Databases

SQL: Structured Query Language

Course Schedule

Day 1. Introduction, Writing PhP Statements, Variables&Data
Day 2. Program Flow
Day 3. Web Application Basics
Day 4. Working with MySQL
Day 5. Presentation


Introduction

PHP: A Brief History

PHP: Personal Homepage, or Hypertext Preprocessor
(1995), a Perl/CGI script
Official Name: PHP (Page Hypertext Preprocessor)
(A recursive acronym)

Version 5 - 2004, current version
PHP is best summarized as an embedded server-side
Web-scripting language that provides developers with
the capability to quickly and efficiently build
dynamic Web applications.
Note: You can put PHP code anywhere in the code.

Client-Server architecture
Explain client-server relationship
Source: http://en.wikipedia.org/wiki/Client-server
"
Client-server
From Wikipedia, the free encyclopedia
Jump to: navigation, search
Client-server is computing architecture which
separates a client from a server, and is almost always
implemented over a computer network. Each client or
server connected to a network can also be referred to
as a node. The most basic type of client-server
architecture employs only two types of nodes: clients
and servers. This type of architecture is sometimes
referred to as two-tier. It allows devices to share
files and resources.

Each instance of the client software can send data
requests to one or more connected servers. In turn,
the servers can accept these requests, process them,
and return the requested information to the client.
Although this concept can be applied for a variety of
reasons to many different kinds of applications, the
architecture remains fundamentally the same.
These days, clients are most often web browsers,
although that has not always been the case. Servers
typically include web servers, database servers and
mail servers.
"
Keyword: request
Situation: you opened a browser, and a pop-up window
opened
(something made a request, e.g. friendster,...
spyware, virus, etc.)
Summary:
client - user
browser - client-appl;ication
server - responds to your request
PHP bears a close resemblance to the C programming
language
Integrates features from a multitude of languages,
including Perl, Java and C++
Extensive support is offered for graphic creation and
manipulation, mathematical calculations, and
E-commerce
Question: Disadvantage
Why does PHP creates a disadvantage at times?
Answer: Maintenance problem 9developer tends to be
lazy, creates bad habits, hard for a programmer to
move into other modes of programming)
Advantages
Related technology: AJAX
Ajax
for web 2.0
http://en.wikipedia.org/wiki/Ajax_%28programming%29
This page pertains to AJAX used in programming
(Asynchronous Javascript And XML) to view other
possible meanings of AJAX, please visit Ajax
(disambiguation)
"
Ajax, or AJAX, is a web development technique used for
creating interactive web applications. The intent is
to make web pages feel more responsive by exchanging
small amounts of data with the server behind the
scenes, so that the entire web page does not have to
be reloaded each time the user requests a change. This
is intended to increase the web page's interactivity,
speed, functionality, and usability.
The name is shorthand for Asynchronous JavaScript and
XML. Ajax is asynchronous in that loading does not
interfere with normal page loading. JavaScript is the
programming language in which Ajax function calls are
made. Data retrieved using the technique is commonly
formatted using XML, as reflected in the naming of the
XMLHttpRequest object from which Ajax is derived.
Ajax is a cross-platform technique usable on many
different operating systems, computer architectures,
and Web browsers as it is based on open standards such
as JavaScript and XML, together with open source
implementations of other required technologies.
"
Old School: Websites were merely publsihing contents
Web 2.0: More about participation
Time Person of the Year : YOU (you as a contributore,
e.g. YouTube )
Question: What is Open Source?
http://en.wikipedia.org/wiki/Open_source
"
Open source is a set of principles and practices that
promote access to the design and production of goods
and knowledge. The term is most commonly applied to
the source code of software that is available to the
general public with relaxed or non-existent
intellectual property restrictions. This allows users
to create software content through incremental
individual effort or through collaboration.
The open source model of operation can be extended to
open source culture in decision making, which allows
concurrent input of different agendas, approaches and
priorities, in contrast with more centralized models
of development such as those typically used in
commercial companies.[1] Open source culture is one
where collective decisions or fixations are shared
during development and made generally available in the
public domain, as done in Wikipedia. This collective
approach moderates ethical concerns over a "conflict
of roles" or conflict of interest. Participants in
such a culture are able to modify the collective
outcomes and share them with the community. Some
consider open source as one of various possible design
approaches, while others consider it a critical
strategic element of their operations.
Before the term open source became popular, developers
and producers used various phrases to describe the
concept; the term gained popularity with the rise of
the Internet which enabled diverse production models,
communication paths and interactive communities.[2]
Later, open source software became the most prominent
face of open source practices.
"
Source code is available ot the public under a certain
license agreement
PHP is open source
Apache and IIS are web servers
Blog: wordpress uses PHP, yahoo
What is an IP address: unique identifier for the
server on the net, IPV4, 32 bit
http://en.wikipedia.org/wiki/IP_address
An IP address (Internet Protocol address) is a unique
address that certain electronic devices use in order
to identify and communicate with each other on a
computer network utilizing the Internet Protocol
standard (IP)—in simpler terms, a computer address.
Any participating network device—including routers,
computers, time-servers, printers, Internet fax
machines, and some telephones—can have their own
unique address.
"
An IP address can also be thought of as the equivalent
of a street address or a phone number (compare: VoIP
(voice over (the) internet protocol)) for a computer
or other network device on the Internet. Just as each
street address and phone number uniquely identifies a
building or telephone, an IP address can uniquely
identify a specific computer or other network device
on a network. An IP address differs from other contact
information, however, because the linkage of a user's
IP address to his/her name is not publicly available
information.
IP addresses can appear to be shared by multiple
client devices either because they are part of a
shared hosting web server environment or because a
network address translator (NAT) or proxy server acts
as an intermediary agent on behalf of its customers,
in which case the real originating IP addresses might
be hidden from the server receiving a request. A
common practice is to have a NAT hide a large number
of IP addresses, in the private address space defined
by RFC 1918, an address block that cannot be routed on
the public Internet. Only the "outside" interface(s)
of the NAT need to have Internet-routable addresses.
Most commonly, the NAT device maps TCP or UDP port
numbers on the outside to individual private addresses
on the inside. Just as there may be site-specific
extensions on a telephone number, the port numbers are
site-specific extensions to an IP address.
IP addresses are managed and created by the Internet
Assigned Numbers Authority (IANA). The IANA generally
allocates super-blocks to Regional Internet
Registries, who in turn allocate smaller blocks to
Internet service providers and enterprises.
"
PHP is free
PHP website: http://www.php.net/
http://www.php.net/license/
How PHP Works with the Web Server
* It all begins when a browser makes a request for a
Web page
* Based on the URL, the browser resolves the address
of the Web server, idnetifies the page it would like,
and gives any other informatio the Web server may
need.
You can work with Indows with PHP
".php" files should be placed in a particular folder
server: request
client: respond
they don't have to be in two distinct machines
Note: Even though you are not in a network, the IP
address assigned to your computer will still work
(deafult setting)
127.0.0.1 (Home IP address)
Domain Names - associated with IP address
path
C:\Program Files\xampp\htdocs
http://localhost/xampp/index.php


WRITING PHP STATEMENTS

Simple Statements
One line statemens
Ends with semicolon (;)

Example:

Echo ("Hello World!");

No comments: