Upload
tobias-palmer
View
216
Download
2
Tags:
Embed Size (px)
Citation preview
Contact Information
Email – [email protected]
Lecturer is a part time member of staff. Students are encouraged to use email to make an appointment.
Resources
Website – to be provided
Set Text - Yank, K., C 2007. Build your own Database Driven Website using PHP & MySQL., Sitepoint, Collingwood, Victoria
Recommended Text - Valade, J.;C 2006. PHP and MySQL, Your Visual Blueprint for Creating Dynamic, Database-driven Web Sites. Hungry Minds Inc, U.S.
Schedule Duration Topics
Week 1( Jul 25)
PHP Syntax
Week 2(July 31)
PHP Operators, expressions, constructs
Week 3(Aug 7)
PHP Forms, server validation, email
Week 4(Aug 14)
MySql Concepts
Week 5( Aug 21)
Handling Databases PHP
Week 6(Aug 28)
File and IO operationsString manipulation
Week 7(Sep 4)
MVC Patterns PHP
Week 8(Sep 18)
Session and Cookies
Week 9(Sep 25)
PHP & Ajax
Week 10(Oct 2)
Libraries
Week 11(Oct 9)
Object Oriented PHP
Week 12(Oct 16)
Exam
Item FocusValu
eDeliverables Due Date
Prac ExercisesCode Exercises (Week1-Week4)
10% Series of exercises Week 4
Assignment
Dynamic Web Site 50% Project BriefData ModelPrototypeWorking System Presentation Class
Week 5Week 5Week 8 Week 11Week 11
Exam 40% 3 hour paper
Assessment
What is Server Side Scripting
Server side scripting refers to operations (scripts) that are executed on the server before feeding information to the browser Examples: ASP, PHP, Java Servlets, JSP, CGI, etc
What is PHP
Stands for Hypertext Preprocessor General Purpose Scripting language. Usually runs in a Web server Initially interpreted, compiled after PHP4 Loosely-typed (does not do type checks) Procedural or Object Oriented (you choose) PHP is case-sensitive
History of PHP
Started 1994 as a set of CGI binaries written in C First Release 1995 PHP v2 PHP v3 1997, Parser has been rewrote PHP v4 2004, Zend Engine, compiler PHP v5 2008, Object Support
Basic Syntax
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head><title>Hello World</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css" >
</head>
<body>
<?php echo "Hello World"; ?>
</body>
</html>
Basic Syntax
Operators
> Bigger than
< Smaller than
== Equal
=== Equal type
=! Different
? Ternary
++ Increment
-- Decrement
&& And
|| or
Basic Syntax
Variables
Variables are prefixed with a dollar symbol and a type does not need to be specified in advance
Basic Syntax
Variables
$x = 1;
$y = 2;
$z= x+y;
echo z;
$x = “Hello”;
$y = “World”;
$z= x.” “.y;
echo z;
Basic Syntax
Loopsfor ($n=0;$n<5;$n++){
echo $n;
}
while (condition)
do something
}
foreach ($array as $key){
echo $key;
}
Basic Syntax
Arrays
$a = array();
$a[0]=1;
$a[1]=12;
$a = array();
$a[‘car1’]=‘red’;
$a[‘car2’]=‘green’;
Basic Syntax
Functions
function show($a){
echo ($a);
}
show(12);
function sum($a,$b=20){
return ($a+$b)
}
echo sum(1);
echo sum(1,5);
Basic Syntax
Native Functions
http://www.php.net/quickref.php
PHP has hundreds of base functions and thousands more from extensions
Google and PHP Manual are the developer’s best friends
Debugging PHP
Using echo Using die() Using print_rUsing debuggers (http://www.easyeclipse.org/site/plugins/phpeclipse.html)
Exercises
Display all even numbers between 0 and 6 using an echo statement
Write a function that compares two numbers and echos which one is bigger
Load an array with numbers and iterate through them echoing which numbers are odd or even, use the foreach iterator
Write a function that returns the current date with the full textual representation of the month ie: 12 January 2008