What is PHP? IDIA 618.185 Fall 2014 Bridget M Blodgett.

Slides:



Advertisements
Similar presentations
Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: The Basics.
Advertisements

Introduction to PHP Dr. Charles Severance
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Introduction to scripting
PHP: Introduction By Trevor Adams.
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”
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 03.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
1 Introduction to PHP. 2 What is this “PHP” thing? Official description: “PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source.
PHP : Hypertext Preprocessor
CSC 405: Web Application And Engineering II 2.1 Web Programming with PHP Introduction to Web programming Introduction to Web programming The programming.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
University of Sunderland Lecture 1 Internet Software Architectures Lecture 1: Introduction.
INTERNET APPLICATION DEVELOPMENT For More visit:
Nael Alian Introduction to PHP
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
2440: 211 Interactive Web Programming Expressions & Operators.
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.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Open Source Software Unit – 3 Presented By Mr. R.Aravindhan.
PHP and JavaScript Nov. 26, 2013 Kyung Eun Park Computer and Creativity (COSC109) Towson University.
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.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
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.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
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.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
PHP Workshop ‹#› أطلق إبداعك 2 أطلق إبداعك 2 مدرس معتمد من مركز زووم PHP: The Basics.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
FP512 WEB PROGRAMMING 1 PREPARED BY: PN. NUR SYUHADA BINTI MOHAMAD.
Chapter 3 Introduction to PHP. Incorporating PHP Within HTML By default, PHP documents end with the extension.php files ending with.htm or.html to also.
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.
Session 2: PHP Language Basics iNET Academy Open Source Web Development.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
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.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Module 1 Introduction to JavaScript
Introduction to Dynamic Web Programming
Chapter 6 JavaScript: Introduction to Scripting
CHAPTER 5 SERVER SIDE SCRIPTING
PHP Introduction.
Intro to PHP & Variables
JavaScript an introduction.
Exercises on JavaScript & Revision
Number and String Operations
WEB PROGRAMMING JavaScript.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Intro to PHP.
Tutorial 10: Programming with javascript
Web Programming and Design
Presentation transcript:

What is PHP? IDIA Fall 2014 Bridget M Blodgett

Class Overview Introduction What is PHP? How to use PHP? 2

Router (Wireless/ Wired) Modem ISP Web server Webpage Video Game Other Home Network The “Internet” Other “Personal” Network User User User User DNSes External IP Router with NAT Internal IP Router with NAT 3

4

5

How are “dynamic” pages different from static or basic web pages? 6

What is PHP? Originally stood for Personal Home Page but since changed to PHP: Hypertext Preprocessor One of the “winners” of the Web 1.0+ wars – Integration with MySQL – Adopted easy and recognizable syntaxes – Extends and works well with HTML and XML One of the first languages to be embedded IN the browser page – Why would this be useful? 7

What is PHP? PHP files work as long as the web server has PHP running and the file ends in.php Output most of the results of the processing as HTML files However, you can also parse.html and.htm files through the PHP server as well – Why would web administrators want to do this? 8

Server vs. Client Side PHP is a server side processing language – This means that only finished results are sent to the user’s computer – All the important data is stored on the server and never leaves it This is different from a language like JavaScript which is a client side language – In which your code and all the processing is done by the user’s computer 9

What Are Syntaxes? Syntax is the grammar of computer languages – PHP draws upon two main types C Syntax – Use of curly brackets, semicolons, role of whitespace perl Syntax – $ to being variable names, associative arrays 10

Philosophy of PHP* You are a responsible and intelligent programmer You know what you want to do Some flexibility in syntax is OK – style choices are OK Lets make this as convenient as possible Sometimes errors fail silently 11*As borrowed from

What Is Needed For PHP? Ideally just ending a file in.php makes it a PHP file, even if all the content is HTML Beyond that the tags are needed to indicate sections that contain PHP code (so the parser knows when to start reading) All the HTML in a page can be output from within these PHP tags or the tags can be embedded within the HTML 12

Embedding PHP For this class most of our PHP will be embedded in a basic HTML page – Although pages of “pure” PHP will also work Embedding your PHP code is useful because it allows for some styling to be applied to the output 13

I am going to say hello. 14 <?php echo “ ”; echo “ I am going to say hello.” echo “Hello!”; echo “ ”; ?>

Commenting Comments are extremely important – They allow others to understand what each part of your code does – They allow you to remember what you were trying to do – They can often act as the basis for a guide or user manual for other who may need to edit/update your code 15

Comment Types Two types of comments – Single Line \\ Good for removing a single line of code Adds literal comments to the end of a line of code – Multi-line /* */ Good for removing blocks of code (that may not be working) Can’t be nested (one put around another) 16

Semicolons Every PHP statement must end with a semicolon If the PHP parser doesn’t see one it will assume each line is connected – Results in weird output and errors Single most common error when programming in PHP 17

PHP Variables Must have a $ before their name Can contain a-z, A-Z, 0-9, or start with _ Capitalization matters! – $Class, $class, $CLASS, $ClAsS are all different variables Spelling Matters – From the book Referer and Referrer are two different names Reserved words cannot be used 18

PHP Keywords 19

Other Reserved Words Language constructs Compile-time constants 20

Strings Strings are one type of variable – They contain letters or whole phrases – Can be assigned directly to a variable – Or can be read from user input (we’ll address this later) 21

Numbers PHP doesn’t have classifications of the types of numbers that it accepts – $num = 4 – $num = 3.14 Both are equally valid as variables 22

Arrays Method of storing larger amounts of information that is related in some way e.g. The names of your intramural team $team = array('Bill', 'Joe', 'Mike', 'Chris', 'Jim'); Arrays begin counting at 0 and go up 23

N-Dimensional Arrays An array of arrays Holds multiple pieces of information – Sometimes of different types Keeps the relationships between those pieces whole Warehouses at Amazon.com 24

Operators OperatorDescriptionExample +Addition$j + 1 -Subtraction$j - 6 *Multiplication$j * 11 /Division$j / 4 %Modulus (division remainder) $j % 9 ++Increment ++ $j --Decrement -- $j 25 Table 3-1. Arithmetic operators

OperatorExampleEquivalent to =$j = 15 +=$j += 5$j = $j + 5 -=$j -= 3$j = $j - 3 *=$j *= 8$j = $j * 8 /=$j /= 16$j = $j / 16.=$j.= $k$j = $j. $k %=$j %= 4$j = $j % 4 26 Table 3-2. Assignment operators

27 OperatorDescriptionExample ==Is equal to$j == 4 !=Is not equal to$j != 21 >Is greater than $j > 3 <Is less than $j < 100 >=Is greater than or equal to$j >= 15 <=Is less than or equal to$j <= 8 Table 3-3. Comparison operators

OperatorDescriptionExample && And $j == 3 && $k == 2 andLow-precedence and $j == 3 and $k == 2 || Or $j 10 orLow-precedence or $j 10 ! Not ! ($j == $k) xor Exclusive or $j xor $k 28 Table 3-4. Logical operators

Variable Assignment Variable assignment is a bit tricky because it uses the =. – This does not mean a literal = like in mathematics. It means that the item on the right is being put into a container labeled the item on the right Can assign values (numbers, strings, etc) or other variables – $val = 3 + 4; – $val = $sum; 29

String Concatenation Concatenating a string is appending the value of another variable or string to the end of an existing string – echo "You have ". $msgs. " messages."; – $bulletin.= $newsflash; 30

String Types Literal Strings – All the formatting and whitespace is preserved – $info = 'Preface variables with a $ like this: $variable'; Double quotes strings – Any formatting within the string may not be preserved – Any variable names will be parsed as variables – echo "There have been $count presidents of the US"; 31

Escapes Escapes or escaping characters are used to keep the parser as reading some character in a certain way – Using quotes within a string will require escapes since otherwise the parser will assume you’re trying to end the string! – $text = 'My sister\'s car is a Ford'; You can also insert special characters (\t, \n, \r) – $heading = "Date\tName\tPayment"; 32