DBW - PHP DBW2017.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 3 PHP (2) : Functions, User Defined Functions & Environment Variables.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
PHP and the Web: Session : 4. Predefined variables PHP provides a large number of predefined global variables to any script which it runs also called.
PHP (2) – Functions, Arrays, Databases, and sessions.
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.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
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: Hypertext Processor Fred Durao
ALBERT WAVERING BOBBY SENG. Week Whatever: PHP  Announcements/questions/complaints.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
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.
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.
INTERNET APPLICATION DEVELOPMENT For More visit:
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
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.
Chapter 8 Cookies And Security JavaScript, Third Edition.
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.
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.
Website Development with PHP and MySQL Saving Data.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
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 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.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
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,
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
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.
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.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 13 Scott Marino.
Radoslav Georgiev Telerik Corporation
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
CGS 3066: Web Programming and Design Spring 2017
Session 2 Basics of PHP.
Introduction to Dynamic Web Programming
CS 371 Web Application Programming
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Database Programming Using PHP
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Introduction.
Software Engineering for Internet Applications
PHP.
Web DB Programming: PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Lecture 5: Functions and Parameters
Web Programming Language
Intro to PHP.
Tutorial 6 PHP & MySQL Li Xu
Tutorial 10: Programming with javascript
PHP: Hypertext Preprocessor
PHP an introduction.
PHP-II.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

DBW - PHP DBW2017

PHP: PHP hypertext processor PHP is a “embedded” language. Source code is included into normal HTML pages and executed by the web server Most text is written as HTML outside PHP code. Source code is enclosed in <?php ……?> <script language=“php”> …..</script> Or <? ….. ?> for short (not always available) <?= ….?> shorcut for including PHP output in HTML. PHP is a full featured language, but it is used mainly in web applications PHP has extensions for PDF, Flash, Databases,…

PHP scripts Usually stored as …php files. Server should configured to handle php files. No special directory (like cgi-bin) required. Can be run as external CGI applications (not recommended) or executed by the web server. Mostly used in combination with MySQL Syntax similar to PERL

Data types Primitive: Complex Variable scope is always local!! Boolean, integer, float, string No need to declare Numerical and string types can be interpreted as boolean (like PERL) Complex Array (both lists and hashes), object Variable scope is always local!! Global variables must be declared explicitly (global $...), or used from $GLOBALS[…]

Arrays Lists and hashes use the same format Creating arrays $array = Array (1,2,3,4,5,6); $array = Array (key1 => 1, key2 => 2, …); Numeric keys are used as indexes!! Values can be of any type $array = Array (key1 => Array (1,2,3,4,5), key2=>3); Elements are recovered as $array[key] $array[] = New_element goes to the end of the array

Predefined variables (Superglobals) $GLOBALS (all of them) $_SERVER (Server set vars, from CGI protocol) $_GET (arguments of GET requests) $_POST (arguments of POST requests) $_COOKIE (cookies sent by the user) $_FILES (uploades files) $_ENV (S.O. environment vars) $_REQUEST ($_GET and $_POST) $_SESSION (persistent vars)

Forms Variables $_GET or $_POST and $_REQUEST are set automatically Special characters are escaped (\) to avoid problems Multiple values can be passed from forms if name is set to “something[]” <input type=“text” name=“param[]” size=“30”> <select name=“values[]” multiple>…</select> PHP changes special characters in field names by “-”

Control structures While (cond) {BLOCK} Do {BLOCK} while (cond) If (cond) Command If (cond) {Block} If (cond1) … elseif (cond2) else While (cond) {BLOCK} Do {BLOCK} while (cond) Switch ($var) { case … case … case …}

Functions function name (parameters) {BLOCK} Output is given by “return” Parameters can be passed by value (default) or by reference (indicated by &$...)

Loops For (expr1; expr2; expr3;) {BLOCK} Foreach (expr_array as $val) {BLOCK} Foreach (expr_array as $key => $value) {BLOCK} $key and $value are copies of the original array elements (could be modified) Break / continue (last/next from PERL!)

Cookies PHP Set cookies: Reading cookies: $_COOKIE[“UsersName”]; Setcookie(“UsersName”, $name, time()+3600, ‘/’, “.mmb.pcb.ub.es”); Reading cookies: $_COOKIE[“UsersName”];

Sessions in Apache/PHP Apache web servers and PHP automatically send identification Cookies, and have a Session space assigned to every ID. PHP can store data variables in Session space. Those variables are available as long as user ID is identified session_start (); a) session_register(“MySessionVar"); $MySessionVar[“user"]=$user; session_register(“$user"); $user=“Pepe”; b) $_SESSION[‘user’] = “Pepe”; Session persistence is normally based in the used of cookies. If cookies are not available, PHP adds a PHPSESSIONID hidden field to all forms

File uploads Requires a special encoding format to be declared in <form…enctype=“multipart/form-data”> and entries like <input name=“userfile” type=“file”…> Information about uploaded files is in $_FILES $_FILES[“userfile”][“name”] $_FILES[“userfile”][“type”] $_FILES[“userfile”][“tmp_name”] $_FILES[“userfile”][“size”] $_FILES[“userfile”][“error”] move_uploaded_file ($filename, $new_destination)