PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
IST 221 Internet Concepts and Applications Introduction to PHP.
PHP Intro/Overview Squirrel Book pages Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a.
Guide To UNIX Using Linux Third Edition
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 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.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 03.
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.
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.
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.
CSC 405: Web Application And Engineering II 2.1 Web Programming with PHP Introduction to Web programming Introduction to Web programming The programming.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
University of Sunderland Lecture 1 Internet Software Architectures Lecture 1: Introduction.
INTERNET APPLICATION DEVELOPMENT For More visit:
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
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.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
PHP By Sergio Rodriguez By Sergio Rodriguez. PHP G PHP: Hypertext Preprocessor G Scripting language G PHP: Hypertext Preprocessor G Scripting language.
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.
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
PHP Teresa Worner. What is it? PHP: Hypertext Preprocessor server-side scripting language open source cross-platform compatible with almost all servers.php.php3.phtml.
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.
PHP PHP: Hypertext Preprocesor Personal Home Page Tools.
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.
PHP - 1h. How it works Client requests document Server loads document in memory Server processes document with relevant module (PHP) Server sends XHTML.
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.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Chapter 1 Introduction to PHP Part 1. Textbook’s Code DOWNLOADS PHP and MySQL for Dynamic Web Sites Complete Set of Scripts.
CSC 405: Web Application Engineering II 2.1 Web Programming with PHP Introduction to Web programming Introduction to Web programming The programming language.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
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.
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,
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
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.
1 1 إعداد : عبدالرحمن محجوب حمد م 2017 تقنيات الانترنت 2 mtc.edu.sd.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
CS 371 Web Application Programming
Introduction to PHP Part 1
Web Database Programming Using PHP
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Intro/Overview Bird Book pages 1-11,
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
PHP: Hypertext Preprocessor
PHP an introduction.
Presentation transcript:

PHP H ypertext P re-processor

Unit 6 - PHP - Hello World! - Data types - Control structures - Operators

Why do we need PHP? ● Dynamic data-driven web sites – Display dynamic information to users – Collect information from users ● Examples: – Online shopping site – Web forum – Newspaper site – etc

Options ● Perl ● Microsoft ASP.NET ● JSP ● ColdFusion ● XSLT ● others

PHP Strengths ● High Performance ● Interfaces with many database systems ● Built-in libraries ● Low cost ● Open source ● Support ● Easy to learn and use

What is PHP? ● Server-side scripting language ● Conceived in 1994 ● Open Source ● Current version is 5 ● Reference page:

How to use this lecture ● Just listen to it ● You won’t remember everything – that’s ok. That’s normal. ● Ask questions if they occur to you. ● Refer back to this presentation if you need to. ● Or refer to:

How it works ● Client requests document ● Server loads document in memory ● Server processes document with relevant module (PHP) ● Server sends HTML document to client ● Client displays document

Hello World!

Hello World!

Output Hello World!

echo 'Hello World';

Output 1 Hello World

Output 2 Hello World

Hello World! Hello World " ?>

Output 1 Hello World

Output 2 Hello World

PHP Basics

PHP Syntax basics ● PHP code embedded in ● Files containing PHP code must have a.php extension (or php3, etc) ● Syntax very similar to C and Java – Statements delimited by ; – Comments as in C/Java: ● /* comment */ ● // comment – But also: # comment ● Variables preceded by $, for example: – $x = 2; – $first_name = joe; ● More on variables later …

Data Types

Data types ● Integer – for whole numbers ● Float – for real numbers ● String – for strings of characters ● Boolean – for true or false values ● Array – For collections of data ● Object – For OO programming

<?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo $first_name; Output: John

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo '$first_name'; Output: $first_name

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo "$first_name"; Output: John

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo "Your name is: $first_name $last_name"; Output: Your name is: John Doe

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo "You said: \"my name is $first_name $last_name\""; Output: Your said: “my name is John Doe”

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo "... And you are worth \$2M"; Output:... And you are worth $2M

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo $first_name[0]; Output: J

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo substr('abcdef', 1, 4); Output: bcde

Strings <?php ?> Strings $first_name = 'John'; $last_name = 'Doe'; echo substr($first_name, 0, 6); Output: ? (guess and write it down)

Strings ● No / Single / Double quote ● String type: ● Functions available:

Integers and Floats <?php $a = 1234; $b = 12.02; ?> ● Integer type: ● Float type:

Boolean ● Logical operators: – And: && – Or: ¦¦ – Not: ! ● Boolean type:

Array idFirst NameLast NameJob 1JoeSmithSurgeon 2JohnJohnsonNurse 3JackJacksonConsultant 4JimJonesIT

Array Fundamental data structure in PHP Used to store collections of values Multidimensional array: array that contains arrays. Different types of arrays: 1. Numerically indexed arrays 2. Non-numerically indexed arrays 3. Does it make any difference?

1. Numerically indexed array <?php $names = array( ); ?> 'Joe', 'John', 'Jack','Jim' echo $names[1]; Output: John

2. Non-numerically indexed array <?php $record = array( ?> firstName => 'John', lastName => 'Smith'); echo $record[lastName]; Output: Smith

3. Key-value pairs <?php $arr = array( ); echo $arr[1]; ?> Output: … 0 => 'Joe', 1 => 'John', 2 => 'Jack', 3 => 'Jim'

Multidimensional arrays <?php $record = array( ); /* i.e. an array of arrays */ array(firstName => 'Joe', lastName => "McDonald"), array(firstName => 'John', lastName => "Smith"), array(firstName => 'Jack', lastName => "Black")

Multidimensional arrays... echo $record[1][lastName]; echo ' '; echo $record[1][1]; ?> Output: …

Operators Directed study

Control structures

if, else, elseif <?php $value = 24; ?> if ($value < 20) echo “not enough!”; elseif ($value < 30) echo “reasonable.”; elseif ($value < 40) echo “perfect!”; else echo “Too much!”;

switch <?php switch ($value){ }?> case 24: echo "Correct!"; break; case 25: echo "Almost correct!"; break; default: echo "Too much!";

for <?php for ( ; ; ) { } ?> ($i = 1$i <= 10 $i++ echo $i; Output:

foreach <?php ?> $arr = array("one", "two", "three"); echo "Using a for loop: \n"; for ($i = 0; $i < sizeof($arr); $i++) { echo "Value: $arr[$i] \n"; } echo "Using a foreach loop: \n"; foreach ($arr as $value) { echo "Value: $value \n"; }

while <?php $i = 1; while ($i <= 10) { echo $i; i++; } Output:

Summary ● Basics ● Data types ● Control structures ● Operators - Directed study: – Arithmetic operators – Comparison operators – Logical operators – String operators