PHP PHP: Hypertext Preprocesor Personal Home Page Tools.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Everyday Italian Giada De Laurentiis Harry Potter J K. Rowling Learning XML Erik T. Ray CSCI 305 Introduction to Database.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic 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.
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.
Objectives Connect to MySQL from PHP
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.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
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”
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
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 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 == ‘ Hypertext Preprocessor ’ Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP.
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.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
An Introduction to PHP The University of Tennessee at Chattanooga C. Daniel Chase “An introduction to basic PHP use with a focus on the power of dynamic.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
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.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
PHP By Sergio Rodriguez By Sergio Rodriguez. PHP G PHP: Hypertext Preprocessor G Scripting language G PHP: Hypertext Preprocessor G Scripting language.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
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.
Perl Practical(?)‏ Extraction and Report Language.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
1 PHP Introduction Chapter 1. Syntax and language constructs.
CS320 Web and Internet Programming Introduction to PHP Chengyu Sun California State University, Los Angeles.
CS 174: Web Programming September 2 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
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.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
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.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
PHP A very brief introduction PHP1. PHP = PHP: Hypertext Processor A recursive acronym! PHP scripts are executed on the server side Executed by (a plugin.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
PHP Training Senior Design team Ongo8 Sunday October 16, 2005.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
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,
CGS 3066: Web Programming and Design Spring 2016 PHP.
PHP – PHP Hypertext Processor A quick overview. How is PHP used? Embedded with HTML, e.g. Not like CGI: PHP files not an executable Used with servers.
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.
Radoslav Georgiev Telerik Corporation
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
DBW - PHP DBW2017.
PHP Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in.
PHP (PHP: Hypertext Preprocessor)
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 an introduction.
23 PHP.
Presentation transcript:

PHP PHP: Hypertext Preprocesor Personal Home Page Tools

Features scripting to generate dynamic content is embedded inside an XHTML page similar in syntax to Perl (sort of)‏ similar to server side inculdes:  web server parses.php file  executes scripts  sends result to client Built-in DB support

Example......

Basic Syntax statements terminated with ; comments:  shell script style: #... (to end of line)‏  C++ style: //... (to end of line)‏  C style: /*... */

Scalar Types boolean: true, false (case insensitive)‏ integer: usual decimal, octal and hex notations floating point: usual notations string:  single quote: 'xyz $abc': no variable interpolation  double quotes: “$abc xyz”: variable interpolation  heredoc: <<<END: multiline strings with varialbe interpolation

Arrays indexed: $a1 = array( “dog”, “cat”, “ant”, “mouse” ); $a1[2] = “snake”; associative: $a2 = array( 'bob'=>24, 'alice'=>33, 'ted'=>12 ); $a2['alice'] = 41;

Variables begin with a $ followed by the variable name variable variables: $xyz = 'abc'; $$xyz = 123; // actualy sets the value of $abc ! echo $abc; // prints out 123

Built-in Variables $_SERVER:  associative array containing web server environment variables  e.g. $_SERVER['GATEWAY_INTERFACE'] $_SERVER['REMOTE_ADDR'] $_SERVER['HTTP_ACCEPT']

Built-in Variables $_GET:  form fields submitted with GET $_POST:  form fields submitted with POST

Built-in Variables $_FILES:  form fields of the file type (uploaded files)‏ $_FILES['x']['name'] – name of the file on the client machine $_FILES['x']['type'] – mime type e.g. image/jpeg $_FILES['x']['size'] – file size in bytes $_FILES['x']['tmp_name'] – path specification to a local file containing the contents of the uploaded file

Built-in Variables $_REQUEST:  everything from the $_GET, $_POST, and $_FILES variables

Variable Scope unlike most languages global variables are not visible inside a funciton unless explicitly declared so$a = “hello”; function foo() {funtion foo() { print $a; // nothing !global $a; }print $a; // “hello” }

Operators pretty much as in C/C++ no separate set of comparison operators for strings. operator for concatenating strings + operator for concatenating arrays

Control Flow – if if ( $a > 2 ) {... } elseif ( $b < 10 ) {... } else {... }

Control Flow – for, while, do... while for ( expr1; expr2; expr3 ) {... } while ( expr ) {... } do {... } while ( expr ); continue; break;

foreach used with indexed or associative arrays foreach ( $array_var as $value ) {... } foreach ( $assoc_array as $key => $value ) {...}

Funcitons funciton foo( $arg1, $arg2,..., $argn )‏ {... return $arg1 + $arg3; }... $a = foo( 1, 2, 3,... ); // $a gets 4

Functions – default args funciton foo( $name, $weight = 27 )‏ {... echo $weight; }... foo( 'Bob', 33 ); // outputs 33 foo( 'Ted' ); // outputs 27 all default args should be rightmost in the args list

Functions – reference args funciton foo( &$xyz )‏ {... $xyz = 'Carol'; }... $name = 'Alice'; foo( $name ); echo $name; // outputs 'Carol'

Functions – reference returns $a = 7; $b = 3; funciton &foo( $x )‏ { global $a, $b; if ( $x ) return $a; else return $b; } $c =& foo( 1 ); // $c and $a the same $d =& foo( 0 ); // $d and $b the same

require textual inclusion require 'vars.php'; drops out of php mode into XHTML mode, so included file must have around any code require_once 'vars.php'  ensures a file is included only once per page

mysql_connect $link = mysql_connect( $host, $user, $password ); returns a link identifier on success, FALSE on failure

mysql_select_db mysql_select_db( $dbname, [ $link ] ); returns TRUE on success, FALSE on failure

mysql_query $result = mysql_query( $query, [ $link ] ); returns TRUE or a result set on success, FALSE on failure mysql_affected_rows( [ $link ] );  returns number of affected rows for non-SELECT queries mysql_num_rows( [ $link ] );  returns number of rows in result set for SELECT queries

mysql_fetch_* $iarray = mysql_fetch_row( $result ); fetches the next row in the result set as a regular indexed array $aarray = mysql_fetch_assoc( $result ); fetches the next row in the result set as an associative array

3 Tier Architectures