Download presentation
Presentation is loading. Please wait.
Published byAshley Webb Modified over 9 years ago
1
University of Sunderland Lecture 1 Internet Software Architectures Lecture 1: Introduction
2
University of Sunderland Lecture 1 Objectives By the end of this lecture the student should: Understand the structure and content of the module Understand the advantages and disadvantages of server-side scripting Understand the basic structure of PHP Understand that it is the programmer’s responsibility to ensure correct HTML and correct use of variables
3
University of Sunderland Lecture 1 MIC312 - Introduction 20 credits module PHP, Accessibility, Usability Networks Software agents XML, XHTML Assessed by: –1 assignment, one exam
4
University of Sunderland Lecture 1 MIC312 – Recommended Books Teach Yourself PHP in 24 Hours Matt Zandstra Essential PHP fast Simon Stobart
5
University of Sunderland Lecture 1 PHP Personal Home Page Server-side scripting Server interprets and sends HTML document to browser Available at: www.php.net Server from: www.omnicron.ca –(doesn’t need PHP)
6
University of Sunderland Lecture 1 Server-Side Scripting Advantages –Browser independent –Run programmes not supported by browser –Access data not on browser –Security
7
University of Sunderland Lecture 1 Server-Side Scripting Disadvantages –Requires access to server to process input –Validation more difficult than with, say, JavaScript
8
University of Sunderland Lecture 1 PHP Embedded within HTML tags Similar to C, Perl
9
University of Sunderland Lecture 1 Example Code <?php echo(“Hello World! ”); ?>
10
University of Sunderland Lecture 1 Example Source Hello World!
11
University of Sunderland Lecture 1 Example Output Hello World!
12
University of Sunderland Lecture 1 Programmer’s Responsibility Programmer’s responsibility to ensure html is correct echo(“Hello World ”); will produce? Hello World
13
University of Sunderland Lecture 1 PHP Comments: // or # for single lines /* … */ spans multiple lines
14
University of Sunderland Lecture 1 Variables PHP supports: –Integers –Floating point (double) –Strings –Boolean –Arrays –Objects Start with $ followed by _ or letter Is not strongly typed
15
University of Sunderland Lecture 1 Variables May be assigned by: –Value $var1=$var2; $var1=123; –Reference: $var1=&$var2; Output with echo statement: echo(“Value is “. $var1. ”units”); ‘.’ Concatenates a string
16
University of Sunderland Lecture 1 Variables Print may also be used gettype() checks type settype(var,type) changes type $var1=( type ) $var2 also changes type But: $var1=2; $var2=“hello”; $var2=$var2. $var1; is OK, as is: $var2=$var2*$var1;
17
University of Sunderland Lecture 1 Variables <?php $var1=123; echo("var1 was “. $var1. " "); $var1=12.3; echo("var1 is now “. $var1. " "); $var1="Hello Fred"; echo("and now it is “. $var1." "); ?> $var1=$var1+2; is also allowed here so beware!
18
University of Sunderland Lecture 1 Summary PHP is server-side scripting Script is interpreted by the server, which sends HTML to the browser Programmer’s responsibility to ensure HTML is correct Normal range of types allowed But PHP is not strongly typed Programmer’s responsibility to use variables correctly
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.