Copyright © 2008-2014 Curt Hill PhP History and Introduction.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: The Basics.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
BY: ALBERTO CABEZAS 4/19/2010. INTRODUCTION: PHP is considered today as one of the most famous scripting languages. PHP is widely used as a general purpose.
IST 221 Internet Concepts and Applications Introduction to PHP.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
PHP Workshop ‹#› PHP: The Basics. PHP Workshop ‹#› What is it? PHP is a scripting language commonly used on web servers. –Stands for “PHP: Hypertext Preprocessor”
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
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.
PHP: Hypertext Processor Fred Durao
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
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 == ‘ Hypertext Preprocessor ’ Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP.
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.
PHP : Hypertext Preprocessor
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
Nael Alian Introduction to PHP
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
PHP By Sergio Rodriguez By Sergio Rodriguez. PHP G PHP: Hypertext Preprocessor G Scripting language G PHP: Hypertext Preprocessor G Scripting language.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
1 PHP Introduction Chapter 1. Syntax and language constructs.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Introduction to PHP Advanced Database System Lab no.1.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
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.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Strings, output, quotes and comments
JavaScript Syntax, how to use it in a HTML document
1 CSC 301 Web Programming Charles Frank. PHP – Stands for:  Personal Home Page (originally),  PHP: Hypertext Preprocessor (now; follows GNU’s recursive.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
©John Samuel 2008 Introduction to PHP. ©John Samuel 2008 Objectives At the end of this class the student will be able to; Create and run a simple php.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
CHAPTER 6 Introduction to PHP5 Part I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
PHP Workshop ‹#› أطلق إبداعك 2 أطلق إبداعك 2 مدرس معتمد من مركز زووم PHP: The Basics.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
PHP Syntax You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain.
©John Samuel 2008 Introduction to PHP Note: These slides are not included in coverage for the BIF703 final exam...
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.
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,
IST 210: PHP Basics IST 210: Organization of Data IST2101.
By bscshelp.com 1.  It is a group assignment.  Complete Website design Using Html and Css.  Due date: 10 th December, 2014 (Hard Deadline) 2.
Javascript Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
PHP using MySQL Database for Web Development (part II)
CSC 301 Web Programming Charles Frank.
CHAPTER 5 SERVER SIDE SCRIPTING
PHP (PHP: Hypertext Preprocessor)
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Introduction.
Intro to PHP & Variables
JavaScript an introduction.
PHP.
Intro to PHP.
Tutorial 6 PHP & MySQL Li Xu
Tutorial 10: Programming with javascript
23 PHP.
Presentation transcript:

Copyright © Curt Hill PhP History and Introduction

Beginnings Developed by Rasmus Lerdorf Member of the Apache Group Implemented in approximately 1995 Rasmus wanted to track visitors to his home page The name is the acronym for Personal Home Page –This is a dumb name and so became: PhP: Hypertext Preprocessor Copyright © Curt Hill

Growth Within about two years of release it was very widespread Main focus is on Server Side processing Normally used for forms processing and database access Most common server side language Is and was an open source product – Copyright © Curt Hill

Versions Like most languages PhP has gone through a number of versions The most recent is version 5.6 –Version is current Versions 5.5 and 5.4 are still available with recent bugs fixed Version 4 is still available, but fading fast Copyright © Curt Hill

Server Side Options There are several ways to process data at the server CGI - Common Gateway Interface ASP - Active Server Pages JSP - Java Server Pages Java Servlets Cold Fusion Server side JavaScript Clearly there is a market needing to be serviced Copyright © Curt Hill

Server Side Processing Most of these require spawning an additional thread from the server They are routines that are outside of the server PhP is more like JavaScript –JavaScript is interpreted by the browser –PhP is interpreted by the server Server recognizes PhP by an extension such as.php.php3,.phtml Copyright © Curt Hill

Server or Client Side We typically have one server and a myriad of clients Thus we prefer to let the client machine do as much processing as possible to ease the server workload There are some things that just cannot be done client-side, so we use PhP for this –Such as database access Copyright © Curt Hill

PhP File Contents A PhP file must have PhP code It may also contain HTML or any type of client side script –HTML in the broadest sense: HTML or XHTML The server will either copy or interpret the file –Or both Copyright © Curt Hill

Server Modes When the server sees HTML it merely copies this to the client –Copy mode When the server sees PhP it interprets this –Only the program output reaches the client –Interpret mode Many files have both copy and interpretation PhP is transparent –Client never sees any of it Copyright © Curt Hill

Compilation or Interpretation? Historically PhP has always been interpreted by the server There is a performance penalty for this Types of pre-compilation have been done to speed up the script –Helpful for large and complicated scripts –Eases server workload Copyright © Curt Hill

Language Overview PhP has much in common with both Perl and JavaScript Dynamic typing –No type declaration –Variables may change type during a program Forgiving syntax Large libraries Copyright © Curt Hill

PhP Script Tag The script tag has following form: You may also use There may be multiple scripts in a file This tag is replaced by the program output before the client sees it –Even View Page Source will not show the PhP code Copyright © Curt Hill

Other Tags PhP may also be enclosed in short tags or ASP tags A short tag is just the: An ASP tag is: The previous two are always enabled but these two may need mention in the initialization file of the server Copyright © Curt Hill

Some Reserved Words Copyright © Curt Hill andbreakcaseclassconst continuedeclaredefaultdoecho elseelseifextendsfalsefor foreachfunctionglobalifinclude listnewnotorprint requirereturnstaticswitchthis truevarvirtualxorwhile

Comments Three types Two single line comments: –# - the same as Perl –// - the same as C++/Java Multiple line comments: –Starts with /* –Ends with */ –Similar to C/C++/Java among others Copyright © Curt Hill

Variables Variables must start with a dollar sign This must be followed by letters, underscores or digits Variables are case sensitive Reserved words are not case sensitive There is no way to declare a variable –Just use it Copyright © Curt Hill

Stropping –Marking names with special characters PhP is unusual in that it forces variables to start with a special character, the $ This has several nice results It makes parsing easy No confusion between a variable and anything else A variable may be recognized as a variable even within a string Makes for harder typing Copyright © Curt Hill

Types PhP has four scalar or primitive types: Boolean integer double string There are two structured types: array object Two special types: resource NULL Copyright © Curt Hill

Statements Statements in PhP are terminated by semicolons The last one in a PhP script may be omitted The braces are used to wrap multiple statements into one like in the C family of languages There are two levels of scope –Global scope –Scope of a function body Most of the operators of Java still exist Copyright © Curt Hill

Output There are several output statements of note print, printf and echo Today we will only consider print Form: print “Any string”; Either quote may be used print ‘Hi there.’; Copyright © Curt Hill

Multiline Print Print may output multiple lines: print “This stuff and some more and the last.”; It will actually put out three lines with newlines (\n) in between However, if the recipient is a web browser the redundant white space (including the newline) is compacted Copyright © Curt Hill

Printing variables Very easy Print variables directly: print $count; Variables may be recognized inside double quotes: print “The answer is: $ans”; This makes formatting output easy Copyright © Curt Hill

include The include function inserts another file into the PhP program The form is: include(“filename”); –This file does not need the.php extension The file may be HTML, client script or PhP The server enters copy mode at the beginning of the inclusion Copyright © Curt Hill

As Seen by the Server Copyright © Curt Hill PHP Demo 1 PHP Demo Page #1 Here is the slot. <?php print " Hello World! "; ?> Return to the CIS 420 Home Page.

As Seen by the Browser Copyright © Curt Hill PHP Demo 1 PHP Demo Page #1 Here is the slot. Hello World! Return to the CIS 420 Home Page.

Client View Copyright © Curt Hill

Source Copyright © Curt Hill

Example commentary PhP is typically inside HTML so when it does prints, it uses HTML tags All the PhP disappeared, but the output of the PhP program is retained –All the raw HTML was merely copied Copyright © Curt Hill

phpinfo() This function will show you the characteristics of the PhP interpreter on this system It will show things like: –Operating System –PhP version –Configurations information Copyright © Curt Hill

XML Did you notice the similarities between PhP tags and XML? If short tags are enabled this causes some problems One of which is that an XML file will be served as empty Solutions: Only use HTML - no XML header Have PhP write out the XML header Disable short tags Copyright © Curt Hill

Example Copyright © Curt Hill <?php print "<?xml... ?> <!DOCTYPE......

Finally PhP seems to be the most popular of the server side scripting languages –However, there is money to be made here so competition is fierce It has very good libraries for accessing databases –The SQL example pages all use PhP scripts Copyright © Curt Hill