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.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)
PHP Presented by Christine Fang and Ian Stuart ● CS616 Spring 2003.
IST 221 Internet Concepts and Applications Introduction to PHP.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
Intermediate PHP (1) Data Structures, Functions, Basic OO & Error Handling.
Scripting Languages and PHP. Origins Rasmus Lerdorf ‘Personal Home Pages’. Zeev Surashi and Andi Gutmans Open Source PHP version 4 Full information on.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
Web Programming with PHP (1). -Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting,
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”
An Introduction to Web Technologies Ankit Jain 4 th Year, Computer Engg Head – DCETECH.COM.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
PHP Tutorial By RAY BALIKI && ROY GHORAYEB. DEFINITION PHP is a powerful server-side scripting language for creating dynamic and interactive websites.
Copyright © Curt Hill PhP History and Introduction.
INTERNET APPLICATION DEVELOPMENT For More visit:
Introduction to PHP (1) Background, Data Types, Control Structures & Functions.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Nael Alian Introduction to PHP
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Open Source Software Unit – 3 Presented By Mr. R.Aravindhan.
PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
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.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
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.
Introduction to Web Programming. Introduction to PHP What is PHP? What is a PHP File? What is MySQL? Why PHP? Where to Start?
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Introduction to PHP.
Yasar Hussain Malik - NISTE. PHP Origins Rasmus Lerdorf PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP Hypertext Processor’ Other key.
UFCE8V-20-3 Information Systems Development 3 PHP (1) : Data Types, Control Structures, Data Structures, String Handling & Input/Output.
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.
PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
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,
11 – Introduction to PHP(1) Informatics Department Parahyangan Catholic University.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
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.
1 Server Side scripting PHP. 2 What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
A pache M ySQL P hp Robert Mudge Reference:
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
Session 2 Basics of PHP.
Introduction to Dynamic Web Programming
เอกสารประกอบการบรรยายรายวิชา Web Technology
Web Database Programming Using PHP
DBW - PHP DBW2017.
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Introduction.
JavaScript.
PHP.
Web DB Programming: PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming with PHP (1)
PHP an introduction.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

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 SQL, PostgreSQL) –Rich features: XML, PDF, IMAP, LDAP

PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviates for ‘Personal Home Pages’, now ‘PHP Hypertext Processor’ Other key developers: Zeev Surashi and Andi Gutmans (Israel) Open Source PHPPHP version current at UWE Due to upgrade to PHP 5

Scripting languages A scripting language is: –often evolved not designed –cross-platform since interpreter is easy to port –designed to support a specific task – PHP -> Web support –un-typed variables (but values are typed) –implicit variable declaration –implicit type conversion –stored only as script files –compiled on demand –may run on the server (PHP) or the client (Javascript)

PHP details Procedural language –Compare with Javascript which is event-driven C-like syntax - { } ; Extensive Function Library Good Web-server integration –Script embedded in HTML –Easy access to form data and output of HTML pages Not fully object-oriented –Java is fully object oriented – all functions have to be in a class –In PHP, classes are additional but quite simple to use

PHP and HTML HTML-embedded –PHP scripts are essentially HTML pages with the occasional section of PHP script. – PHP script is enclosed in the tag pair:

Free format - white space is ignored Statements are terminated by semi-colon ; Statements grouped by { … } Comments begin with // or a set of comments /* */ Assignment is ‘=’ $a=6 Relational operators are, == ( not a single equal) Control structures include if (cond) {..} else { }, while (cond) {.. }, for(startcond; increment; endcond) { } C-like language

Arrays are accessed with [ ] : $x[4] is the 5th element of the array $x – indexes start at 0 Associative Arrays (hash array in Perl, dictionary in Java) are accessed in the same way: $y[“fred”] Functions are called with the name followed by arguments in a fixed order enclosed in ( ) : substr(“fred”,0,2) Case sensitive - $fred is a different variable to $FRED

Function library Basic tasks –String Handling –Mathematics – random numbers, trig functions.. –Regular Expressions –Date and time handling –File Input and Output And more specific functions for- –Database interaction – MySQL, Oracle, Postgres, Sybase, MSSQL.. –Encryption –Text translation –Image creation –XML

String Handling String literals (constants) enclosed in double quotes “ ” or single quotes ‘ ’ Within “”, variables are replaced by their value: – called variable interpolation. “My name is $name, I think” Within single quoted strings, interpolation doesn’t occur Strings are concatenated (joined end to end) with the dot operator “key”.”board” == “keyboard”

Standard functions exist: strlen(), substr() etc Values of other types can be easily converted to and from strings – numbers implicitly converted to strings in a string context. Regular expressions be used for complex pattern matching.

Learning PHP Start with just the basics, installing a script to output an HTML page Understand how PHP supports interaction with the Browser or other clients Understand how PHP supports integration with databases – Postgress

Basic PHP Syntax

Datatypes String –'My name is Taro Keio.' –"My name is $name." Boolean –true –false Integer –100 –0x1c Floating point Array –array("tokyo", "hanoi", "london") –array("japan" => "tokyo", "vietnam" => "hanoi", "england" => "london") –$a[2] –$a["vietnam"]

Variables in PHP All variables in PHP start with a $ sign symbol. Variables may contain strings, numbers, or arrays.

Variable Naming Rules A variable name must start with a letter or an underscore "_" A variable name can only contain alpha-numeric characters and underscores (a-Z, 0-9, and _ ) A variable name should not contain spaces. If a variable name should be more than one word, it should be separated with underscore ($my_string), or with capitalization ($myString)

Comments in PHP <?php //This is a comment /*This is a comment block*/ ?>

The If...Else Statement Syntax if (condition) code to be executed if condition is true; else code to be executed if condition is false;

Example <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?>

The Switch Statement Syntax switch (expression) { case label1: code to be executed if expression = label1; break; case label2: code to be executed if expression = label2; break; default: code to be executed if expression is different from both label1 and label2; }

Looping while - loops through a block of code if and as long as a specified condition is true do...while - loops through a block of code once, and then repeats the loop as long as a special condition is true for - loops through a block of code a specified number of times foreach - loops through a block of code for each element in an array

The while Statement Syntax while (condition) code to be executed;

The do...while Statement Syntax Do { code to be executed; } while (condition);

The for Statement Syntax for (initialization; condition; increment) { code to be executed; }

The foreach Statement Syntax foreach (array as value) { code to be executed; }

PHP Function <?php function writeMyName() { echo "Kai Jim Refsnes"; } writeMyName(); ?>

PHP Form Handling Name: Age:

welcome.php Welcome. You are years old.