Introduction to PHP “PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Introduction to PHP SOFTWARE FREEDOM DAY1 Introduction to PHP MS. SADAF ABBASI
 HTTP Communication  HTTP Communication for Web  Static  Dynamic  Dynamic Content  PHP  PHP Block  PHP Programming Style  Database  MySQL.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
IST 221 Internet Concepts and Applications Introduction to PHP.
PHP Scripting language Ludovico Antonio Muratori Ci S.B.i.C. snc Cesena, ITALY.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Server side basics.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Server side basics CS URLs and web servers  Usually when you type a URL in your browser:  Your computer looks up the server's IP address using.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
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: Introduction By Trevor Adams.
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.
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.
PHP MOHAMMED SHURRAB TO MISS/ RASHA ATTALLAH. What is PHP? Stands for "PHP Hypertext Preprocessor" Server-side scripting language HTML-embedded Supports.
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
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
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
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.
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.
PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming.
CS320 Web and Internet Programming Introduction to PHP Chengyu Sun California State University, Los Angeles.
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.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Introduction to PHP Advanced Database System Lab no.1.
Web Technology Introduction to PHP. PHP PHP stands for PHP Hypertext Preprocessor PHP is a Server-Side Web Scripting language, which executes on the web.
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
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.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
Introduction to PHP.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
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,
CSE 154 LECTURE 14: INTRO TO PHP. URLs and web servers usually when you type a URL in your browser: your computer looks up the.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
PHP Overview. What is PHP Widely available scripting language Free Alternative to Microsoft’s ASP Runs on the Web Server; not in the browser Example:
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.
CGS 3066: Web Programming and Design Spring 2016 PHP.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
First Steps in PHP Creating Very Simple PHP Scripts SoftUni Team Technical Trainers Software University
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)
Introduction to Dynamic Web Programming
CS 371 Web Application Programming
Introduction to PHP “PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be.
Introduction to PHP “PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be.
PHP Introduction.
Maged Bouchahma University of Nizwa
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Intro to PHP.
PHP an introduction.
Presentation transcript:

Introduction to PHP “PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be executed each time the page is visited. Your PHP code is interpreted at the Web server and generates HTML or other output that the visitor will see” (“PHP and MySQL Web Development”, Luke Welling and Laura Thomson, SAMS)

Introduction to PHP  PHP Hypertext Preprocessor. Other Names : Personal Home Page, Professional Home Page  Is a server side scripting language. Capable of generating the HTML pages  HTML generates the web page with the static text and images.  However the need evolved for dynamic web based application, mostly involving database usage.

CLIENT WEB SERVER HTTP Request (url) Gets Page Hello Interprets the PHP code Server response Browser creates the web page Hello

Why PHP? ..there are no. of server side scripting available like ASP, SSJS, JSP…..  PHP involves simplicity in scripting (..generally using the database) platform independence.  PHP is primarily designed for web applications well optimized for the response times needed for web applications  Is an open source.

PHP Block  PHP code block is embedded within the tags.  When the server encounters the PHP tags it switches from the HTML to PHP mode.  There are four different ways to embed the PHP code echo(“Some PHP code”);

Hello World! (web oriented) My personal Hello World! PHP script <? echo “Hello World!”; ?> PHP tag, allow to insert PHP code. Interpretation by PHP module will substitute the code with code output

Variables (I) To use or assign variable $ must be present before the name of the variable The assign operator is '=' There is no need to declare the type of the variable the current stored value produces an implicit type-casting of the variable. A variable can be used before to be assigned $A = 1; $B = “2”; $C = ($A + $B); // Integer sum $D = $A. $B; // String concatenation echo $C; // prints 3 echo $D;// prints 12

Variables (II) Function isset tests if a variable is assigned or not $A = 1; if (isset($A)) print “A isset” if (!isset($B)) print “B is NOT set”; Using $$ $help = “hiddenVar”; $$help = “hidden Value”; echo $$help; // prints hidden Value $$help = 10; $help = $$help * $$help; echo $help; // print 100

PHP Variables (cont.)  Rich set of functions for working with variable. For e.g  gettype, settype, isset, unset, is_int, intval etc etc

Strings (I) A string is a sequence of chars $stringTest = “this is a sequence of chars”; echo $stringTest[0]; output: t echo $stringTest; output: this is a sequence of chars A single quoted strings is displayed “as-is” $age = 37; $stringTest = 'I am $age years old'; // output: I am $age years old $stringTest = “I am $age years old”; // output: I am 37 years old Concatenation $conc = ”is “.”a “.”composed “.”string”; echo $conc; // output: is a composed string $newConc = 'Also $conc '.$conc; echo $newConc; // output: Also $conc is a composed string

Arrays (I) Groups a set of variables, every element stored into an array as an associated key (index to retrieve the element) $books = array( 0=>”php manual”,1=>”perl manual”,2=>”C manual”); $books = array( 0=>”php manual”,”perl manual”,”C manual”); $books = array (“php manual”,”perl manual”,”C manual”); echo $books[2]; output: C manual Arrays with PHP are associative $books = array( “php manual”=>1,”perl manual”=>1,”C manual”=>1); // HASH echo $books[“perl manual”]; output: 1 $books[“lisp manual”] = 1; // Add a new element

Arrays (II) Working on an arrays $books = array( ”php manual”,”perl manual”,”C manual”); Common loop for ($i=0; $i < count($books); $i++) print ($i+1).”-st book of my library: $books[$i]”; each $books = array( “php manual”=>1,”perl manual”=>2,”C manual”=>3); while ($item = each( $books )) // Retrieve items one by one print $item[“value”].”-st book of my library: ”.$item[“key”]; // each retrieve an array of two elements with key and value of current element each and list while ( list($value,$key) = each( $books )) print “$value-st book of my library: $key”; // list collect the two element retrieved by each and store them in two different // variables

Arrays (II) each and list while ( list($value,$key) = each( $books )) print “$value-st book of my library: $key”; // list collect the two element retrieved by each and store them in two different // variables

Arrays (III) Multidimensional arrays $books = array( array(“title”=>“php manual”,”editor”=>”X”,”author”=>”A”), array(“title”=>“perl manual”,”editor”=>”Y”,”author”=>”B”), array(“title=>“C manual”,”editor”=>”Z”,author=>”C”)); Common loop for ($i=0; $i < count($books); $i++ ) print “$i-st book, title: ”.$books[$i][“title”].” author: “.$books[$i][“author”]. “ editor: “.$books[$i][“editor”]; // Add.”\n” for text new page or “. ” for HTML new page; Use list and each for ($i=0; $i < count($books); $i++) { print “$i-st book is: “; while ( list($key,$value) = each( $books[$i] )) print “$key: $value ”; print “ ”; // or “\n” }

Arrays (cont.)  $ncststaff = array (“dake” => array(“amrish”, “lakshana”, “venkat”), “spc” => array(“narayan”, “murali”,“prasad”));  creates a two dimensional array.  Sorting Functions sort() : sorts the elements in the numeric and alphabetical order. rsort() : sorts the elements in the reverse order. asort() : sorts the elements in the array without changing the indices. ksort() : sorts the arrays by key.

PHP Statements  IF statement if ( ) { //php code goes here } else { //php code goes here }  Alternative Syntax if( ) : //html code goes here else : //html code goes here endif;

PHP Statements (cont.)  For loop for($i=0;$i < 10;$++i) { echo(“the value is :”. $i); } Alternative Syntax for($i=0;$i < 10;$++i) : // html code goes here endfor;  While loop  Do-While loop