School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

1 Database Driven Web Application Clients Application Servers including web servers Database Server Traditional client-server (2-tier architecture): client:
IST 221 Internet Concepts and Applications Introduction to PHP.
Guide To UNIX Using Linux Third Edition
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Server side basics.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Introduction to PHP. PHP PHP is the Hypertext Pre-processor –Script language –Embedded into HTML –Runs as Apache module –Can use DB (MySQL, Oracle, Microsoft.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
ALBERT WAVERING BOBBY SENG. Week Whatever: PHP  Announcements/questions/complaints.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
PHP MOHAMMED SHURRAB TO MISS/ RASHA ATTALLAH. What is PHP? Stands for "PHP Hypertext Preprocessor" Server-side scripting language HTML-embedded Supports.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
Copyright © Curt Hill PhP History and Introduction.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
INTERNET APPLICATION DEVELOPMENT For More visit:
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
Lecture 12 PHP Basics Boriana Koleva Room: C54
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
INTERNET APPLICATION DEVELOPMENT For More visit:
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.
VB and C# Programming Basics. Overview Basic operations String processing Date processing Control structures Functions and subroutines.
PHP. What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Introduction to PHP Advanced Database System Lab no.1.
What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports.
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
CSE 154 LECTURE 5: INTRO TO PHP. URLs and web servers usually when you type a URL in your browser: your computer looks up the.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
CHAPTER 6 Introduction to PHP5 Part I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
CGS 3066: Web Programming and Design Spring 2016 PHP.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP using MySQL Database for Web Development (part II)
CGS 3066: Web Programming and Design Spring 2017
CS 371 Web Application Programming
DBW - PHP DBW2017.
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Introduction.
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming Language
PHP: Hypertext Preprocessor
PHP an introduction.
Intro to Programming (in JavaScript)
Presentation transcript:

School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages

School of Computing and Information Systems CS 371 Web Application Programming Server vs Client side Traditional static web pages Internet clie nt server request is made server receives request sends html file client receives and renders html

School of Computing and Information Systems CS 371 Web Application Programming Server vs Client side Client side processing Internet clie nt server Client clicks on button or element that has event associated with it associated function modifies web page

School of Computing and Information Systems CS 371 Web Application Programming Server vs Client side Server side scripting Internet clie nt server request is made server script processes request (database…) sends back html, xml or other data client receives and processes data

School of Computing and Information Systems CS 371 Web Application Programming Client vs. Server side server scripts web server must support language & features can save and retrieve data source code is hidden client scripts browser must support language (cross browser issues) executed by client does not require refresh

School of Computing and Information Systems CS 371 Web Application Programming Server side scripting history CGI (common gateway interface) since 1993 input was URL appendage: ?=“& characters are converted to hex programs (C, perl) read the data from stdin had to convert data back and assemble web server invokes program as a separate process

School of Computing and Information Systems CS 371 Web Application Programming Server side scripting - newer languages are compiled into web server – directly executed make access to input variables much easier have better integration with database examples: ASP, JSP, PHP, SMX, Lasso, Ruby, etc.

School of Computing and Information Systems CS 371 Web Application Programming PHP PHP: Hypertext Processor Ranked 3 rd on TIOBE index Free Software Foundation – no formal specifications syntax influenced by C and perl 1995 ver 2 - Rasmas Lerdorf created for maint. web pages several updates later, 2004 ver 5, oop, consistent database support, etc.

School of Computing and Information Systems CS 371 Web Application Programming PHP basics files have php extensions but embed HTML acts as a filter – inputs mix of code and HTML, outputs all HTML called: putting URL directly into address of browser <form action=“myProg.php” … code is embedded using

School of Computing and Information Systems CS 371 Web Application Programming PHP more basics like c statements end in ; comments, assignments, operators, control statements, function calls like perl loosely typed variables (also start with $) associative array whitespace echo is stdout

School of Computing and Information Systems CS 371 Web Application Programming Variables identifiers – any length, letters, digits, _ and $ use “=“ for assignment operator types: integer, double, string, boolean, array and object declarations do not use type: $i=0; constants: define(‘MAX’,100);

School of Computing and Information Systems CS 371 Web Application Programming Variable Scope local, global and superglobal all variables are global within the scope they are defined in all variables are local in functions unless specified with global keyword superglobals are a set of variables always available ($_POST(‘name’))

School of Computing and Information Systems CS 371 Web Application Programming Operators arithmetic: +,-, *, / and our old friend % string concatenation $fname. $lname assignment: =, +=, -=, *=, /=, %= and.= ++ and - - are both pre and post fix reference: $b = &$a // $a and $b point to same variable (no pointer arithmetic) comparison: ==, !=, <>,, =, === logical: !, &&, ||, xor Who uses this?

School of Computing and Information Systems CS 371 Web Application Programming Program Structure similar to C, Java: if statements switch statements while, do while and for loops foreach can be used to iterate through collection foreach($myArray as $value) foreach($myArray as $key => $value)

School of Computing and Information Systems CS 371 Web Application Programming Functions do not need to declare return type optional parameters – assign in def functions not case sensitive pass-by-ref: use & before parameter use require() and include() to import code function f($parm1, $parm2, $parm3=1, $parm4=‘a’){ return $parm1 + $parm2 * $parm3 – strlen($parm4); } echo( f(-4, 6) ); echo( f( 3, 4, 2, ‘what’) );

School of Computing and Information Systems CS 371 Web Application Programming Arrays arrays are associative (more like hash maps than arrays) subscripts can be integers or strings declarations: $arr = array(1,2,3,4); $arr = array( 4 => ‘first’, ‘x’ => ‘second’); $arr[3]=‘something’; //creates $arr add element: $arr[]=‘new val’; $value) { unset($array[$i]); //delete item } print_r($array); $array[] = 6; print_r($array); $array = array_values($array); $array[] = 7; print_r($array); ?> Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Array ( ) Array ( [5] => 6 ) Array ( [0] => 6 [1] => 7 )

School of Computing and Information Systems CS 371 Web Application Programming Arrays (cont) multidimensional $persons=array(array(‘al’,21),array(‘flo’,22) ); $persons[0][1] //value would be 21 many helpful array functions sort, count, sizeOf, each(), current, reset(), end(), next(), pos()

School of Computing and Information Systems CS 371 Web Application Programming File Processing like c fopen, fclose, fwrite, fgets, feof, etc. also can use lock functions easier way: $lines = file(“pathName”); creates an array with an element for each line

School of Computing and Information Systems CS 371 Web Application Programming Strings can be delimited by single quotes (only recognizes \\ and \’) double quotes (recognizes more escape seq.) heredoc can use printf, strtoupper, ucfirst… explode(‘,’,$record) //creates array like split in java substr, strcmp, strlen, etc.

School of Computing and Information Systems CS 371 Web Application Programming Classes and Objects members can be private, public or protected constructors and destructors classes can extend other classes use class::method for class methods name = $newName; } public function displayName() { echo $this->name; } } ?> $s = new Student(‘melvin’); $s->displayName();