Top Banner
NMD202 Web Scripting Week1
25

NMD202 Web Scripting Week1. Contact Information Email – [email protected] Lecturer is a part time member of staff. Students are encouraged to use.

Dec 26, 2015

Download

Documents

Tobias Palmer
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

NMD202 Web Scripting

Week1

Page 2: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Contact Information

Email – [email protected]

Lecturer is a part time member of staff. Students are encouraged to use email to make an appointment.

Page 3: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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.

Page 4: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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

Page 5: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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

Page 6: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Code Testing

Cross browser compatibility

Validate against the standards

Web Best Practices

Page 7: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

What we will cover today

What is Server Side Scripting History of PHP Syntax Examples and Exercises

Page 8: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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

Page 9: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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

Page 10: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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

Page 11: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

PHP

The best feature PHP – FlexibilityThe worst feature PHP - Flexibility

Page 12: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

PHP only parses code within its delimiters:

<?php Some PHP code here ?>

Or

<? ?>

Page 13: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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>

Page 14: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Exercise

Setup Development Environment

Do the Hello World example

Page 15: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

Operators

> Bigger than

< Smaller than

== Equal

=== Equal type

=! Different

? Ternary

++ Increment

-- Decrement

&& And

|| or

Page 16: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

Variables

Variables are prefixed with a dollar symbol and a type does not need to be specified in advance

Page 17: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

Variables

$x = 1;

$y = 2;

$z= x+y;

echo z;

$x = “Hello”;

$y = “World”;

$z= x.” “.y;

echo z;

Page 18: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

Loopsfor ($n=0;$n<5;$n++){

echo $n;

}

while (condition)

do something

}

foreach ($array as $key){

echo $key;

}

Page 19: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

Conditional Structures

If (condition)

{

do something

}

else

{

do something else

}

Page 20: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

Conditional Structures

switch (variable){

case x:

do something

break;

…..

}

Page 21: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Basic Syntax

Arrays

$a = array();

$a[0]=1;

$a[1]=12;

$a = array();

$a[‘car1’]=‘red’;

$a[‘car2’]=‘green’;

Page 22: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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);

Page 23: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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

Page 24: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

Debugging PHP

Using echo Using die() Using print_rUsing debuggers (http://www.easyeclipse.org/site/plugins/phpeclipse.html)

Page 25: NMD202 Web Scripting Week1. Contact Information Email – luis.v.n.silva@gmail.com Lecturer is a part time member of staff. Students are encouraged to use.

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