Introduction to PHP 1.What is PHP? What Is PHP?  php: hypertext preprocessor  Server-side scripting language—like ASP—scripts are executed on server.

Slides:



Advertisements
Similar presentations
» PHP arrays are lists of values stored in key-value pairs. » Uses of arrays: Many built-in PHP environment variables. Database functions use arrays.
Advertisements

Objectives Using functions to organize PHP code
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.
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic PHP.
Chapter 4 Functions and Control Structures PHP Programming with MySQL.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
PHPPHP What is PHP? Hypertext Pre-processor (PHPs) is a server- side scripting language In early versions, PHP stand for Personal Home Page. server-side.
WHAT IS PHP PHP is an HTML-embedded scripting language primarily used for dynamic Web applications.
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
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”
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 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 – Get & Post; Functions; and Arrays IS6116 – 07 th February 2011.
Programming with php By: Seth Larson. A little bit about PHP  PHP stands for PHP:  Hypertext Preprocessor  PHP is a widely-used general-purpose server-side.
PHP : Hypertext Preprocessor
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
Mandakini Ayushi Infotech Mandakini Kumari 22 nd July PHP Basic.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
PHP - Hypertext Preprocessor. Introduction PHP is a powerful server-side scripting language for creating dynamic and interactive websites. PHP is a powerful.
Languages in WEB Presented by: Jenisha Kshatriya BCM SS09.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
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.
Nael Alian Introduction to PHP
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
PHP - Introduction Week 5 Dr. Ken Cosh Introducing PHP 1.
Open Source Software Unit – 3 Presented By Mr. R.Aravindhan.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Web Programming Language Week 5 Dr. Ken Cosh Introducing PHP 1.
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.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
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.
Week 4 PHP H ypertext P reprocessor Reference : Official Site :
PHP - 1h. How it works Client requests document Server loads document in memory Server processes document with relevant module (PHP) Server sends XHTML.
PHP Teppo Räisänen LIIKE/OAMK PHP PHP is a programming language for making dynamic and interactive Web pages.
Introduction to PHP.
הרצאה 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.
PHP Introduction PHP is a server-side scripting language.
CST336, Dr. Krzysztof Pietroszek Week 2: PHP. 1.Introduction to PHP 2.Embed PHP code into an HTML web page 3.Generate (output HTML) web page 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,
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
PHP-Basic By- Tanvi Raval. Pre-requisites Before you continue you should have a basic understanding of the following: 1. HTML 2. JavaScript.
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.
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 stands for …….. “PHP Hypertext Pre-processor” and is a server-side scripting language like ASP. PHP scripts are executed on the server PHP supports.
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)
Introduction to Dynamic Web Programming
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
PHP Introduction.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
IntroductionToPHP Static vs. Dynamic websites
Tutorial 6 PHP & MySQL Li Xu
Introduction to PHP.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

Introduction to PHP 1.What is PHP?

What Is PHP?  php: hypertext preprocessor  Server-side scripting language—like ASP—scripts are executed on server  Supports many databases (MySQL, Informix, Oracle, Sybase, PostgreSQL, Generic ODBC, etc.)  Used to manipulate database on the Web

PHP File  Can contain text, HTML tags and scripts  When php code is executed on the server, results are returned to the browser as plain HTML  Files have a file extension of ".php", ".php3", or ".phtml"

Basic PHP Syntax

Comments in PHP

Variables in PHP  Starts with $, followed by alpha or “_”, followed by “A-Z”, “a-z”, or “0”-”9”  Type is not declared but is determined by use  E.g., $name = “John”; $age = 19; $address1 = “3140 Waialae Av”;

String Variables  Given: $firstName = “Mary”; $lastName = “Poppins”;  Catenation $fullName = $firstName. “ “. $lastName; echo $fullName; // prints Mary Poppins  strLen() Function echo strLen($fullName; // prints 12

PHP Operators  Arithmetic +, -, *, /, %  Comparison ==, !=. <>, >, >=. <, <=  Logical &&, ||, !

Conditional Statements  if ($a % 2 == 0) echo $a. “ is even.”;  If ($a % 2 == 0) echo $a. “ is even.”; else echo $a. “ is odd.”;  if (($a > 0) && ($a % 2) == 0 ) { echo $a. “ is positive”; echo $a. “ is even”; }

Iteration Statements  while (some condition is true) { statements; }  do { statements; } while (some condtion is true)  for ($i = 0; $i < $count; $i++){ statements; }  foreach ($array as $value){ echo $value; }

Arrays $names = array(“Ann”, “Bob”, “Cathy”); $ages = array(); $ages[0] = 19; $ages[1] = 23; $ages[2] = 21; $count = 3; for ($i = 0; $i ”; }

Your Turn  Write a php code which initializes parallel arrays $names and $ages with 3 values each and prints their contents in the following format: Mary is 21 years old. Tom is 19 years old. Harry is 22 years old.

Solution \n”; } ?>

Solution2 \n”; } echo $output; ?>

Associative Arrays  Numeric Array E.g.: $ages = array(21, 19, 23, 25); 0  21, 1  19, 2  23, 3  25|  Associative Array E.g. friends “ann”  21, “bob”  19, “cal”  23 E.g., eyeColors “ann”  ”brown”, “bob”  ”blue”, “cal”  ”black”, “dan”  ”green”

Initializing Associative Arrays // Example 1 $friends = array("Ann"=>19, "Bob"=>22, "Cathy"=>20); // Example 2 $eyeColors["Ann"] = "brown"; $eyeColors["Bob"] = "blue"; $eyeColors["Cathy"] = "black";

Printing Associative Array  Given friends “ann”  21, “bob”  19, “cal”  23  echo "Ann is ". $friends["Ann"]. " years old. "; echo "Names and Ages "; print_r($friends);  Output Ann is 21 years old. Array( [Ann] => 21 [Bob] => 19 [Cathy] => 23 )

Associative Array (another example)  $entre = array (“Monday” => “turkey”, “Tuesday” => “pizza”, “Wednesday” => “beef”, “Thursday” => “chicken”, “Friday” => “fish”);  $entre[“Saturday”] = “venison”; $entre[“Sunday”] = “ham”;

Associative Array (cont.)  $size = count($entre) // $size contains 7  To print contents of $entre for ($n = 0; $n ”; }

 for ($n = 0; $n ”; }  each($entre) function -- $today = each($entre); Think of $today as 2-element associative array: $today = (key => “...”, value => “...)

Form Input (getinfo.html) Form Input (html) Name: Age:

Form Input (getinfo.php) Form Input (php) \n”; echo “Are you really “. $_POST[“myAge”]. “ years old? ”; ?>

Form Input (in one file) Form Input (php) \n”; echo “Are you really “. $_POST[“myAge”]; echo “ years old? ”; } ?> Name: Age:

Functions <?php function check($item) { if ($item == "") return false; else return true; } $name = $_POST["myName"]; $ = $_POST["my "]; if (check($name)) echo "Name: ". $name. " "; else echo "Please supply your name. "; if (check($ )) echo " ". $ . " "; else echo "Please supply your . "; ?>