1 CS428 Web Engineering Lecture 19 Data Types (PHP - II)

Slides:



Advertisements
Similar presentations
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 3 PHP (2) : Functions, User Defined Functions & Environment Variables.
Advertisements

Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: The Basics.
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Introducing JavaScript
 PHP's name is an recursive acronym for:  Hypertext Preprocessor  PHP script is an HTML- embedded scriting language  Designed to do something only.
Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
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 Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
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.
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
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.
Chapter 4 Handling User Input PHP Programming with MySQL 2nd Edition
PHP : Hypertext Preprocessor
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
INTERNET APPLICATION DEVELOPMENT For More visit:
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Nael Alian Introduction to PHP
Week 9 PHP Cookies and Session Introduction to JavaScript.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
A little PHP. Enter the simple HTML code seen below.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
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.
Introduction to PHP – Part 2 Sudeshna Dey. Arrays A series of homogeneous elements Elements have values in form of stored data Has a key associated with.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
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.
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
Introduction to PHP.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
CHAPTER 6 Introduction to PHP5 Part I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
Creating PHP Pages Chapter 6 PHP Variables, Constants and Operators.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Chapter 3 Introduction to PHP. Incorporating PHP Within HTML By default, PHP documents end with the extension.php files ending with.htm or.html to also.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 3: Working with PHP Rob Gleasure
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
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.
Session 2: PHP Language Basics iNET Academy Open Source Web Development.
NMD202 Web Scripting Week2. Web site
1 CS428 Web Engineering Lecture 22 Building Dynamic Web pages (PHP - V)
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables Class #4.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
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.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP. What is PHP? PHP Hypertext Processor – Dynamic web development – Scripting language – Can be procedural or OOP(preferred) – PHP code can be embedded.
PHP using MySQL Database for Web Development (part II)
Session 2 Basics of PHP.
>> Fundamental Concepts in PHP
ITM 352 Data types, Variables
Variables Variables are used to store data or information.
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
PHP Introduction.
Intro to PHP & Variables
Perl Variables: Array Web Programming.
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming Language
Presentation transcript:

1 CS428 Web Engineering Lecture 19 Data Types (PHP - II)

Variables Names 1)Start with a $ sign. 2)Followed by a letter or underscore. 3)Can contain letters, numbers, underscores or dashes. 4)No spaces 5)Case sensitive $item $Item $myVariable $this_variable $this-variable $product3 $_book $__bookPage Shouldn’t use as a variable starting with single underscore, because PHP uses single underscore itself to define certain types of variables.

EXAMPLES <?php $var1 = 10; echo $var1; ?> <?php $var2 = “Hello World”; echo $var2; ?> Case Sensitivity with Variables <?php $my_variable = “Hello World”; $my_Variable = “Hello World Again”; echo $my_Variable; ?> Output: Hello World Again

EXAMPLE <?php $var1 = 10; echo $var1; echo “ ”; $var1 = 100; echo $var1; ?> Output:

STRINGS <?php echo “Hello World ”; echo ‘Hello World ’; $my_variable = “Hello World”; echo $my_variable; echo $my_variable. “ Again”; ?> Output: Hello World Again HTML tags can also be used in strings We can also concatenate a string and a variable

EXAMPLE We can use variable in double quotes as well. <?php $my_variable = “Hello World”; ?> <?php echo “$my_variable Again.”; ?> But better way to do this is put variable in curly braces: echo “{$my_variable} Again”;

String Functions <?php $firstString = “The quick brown fox”; $secondString = “ jumped over the lazy dog”; ?> <?php $thirdString = $firstString; $thirdString.= $secondString; echo $thirdString; ?> Output: The quick brown fox jumped over the lazy dog. Another way of concatenation

Lower case: Upper case: Uppercase first-letter: Uppercase words:

Length: Trim: Find: Replace by String: This function removes extra white spaces

MORE STRING FUNCTIONS Repeat: str_repeat($thirdString, 2); Make substring: substr($thirdString, 5, 10); Find position: strpos($thirdString, “brown”); Find character: strchr($thirdString, “z”);

EXAMPLE <?php $var1 = 3; $var2 = 4; ?> <?php $var2 += 4; echo $var2; ?> Output: 8 Increment by 1. Increment: Decrement by 1. Decrement: You can add any value and change the value of variable

FLOATING POINT NUMBERS Floating Point: Round: Ceiling: Floor: Output: Floating Point: 3.14 Round: 3.1 Ceiling: 4 Floor: 3

ARRAYS You can think of an array is a variable, in which you can assign multiple values. Output: 8 Note: array’s position is starting from zero The first pocket is zero.

EXAMPLE <?php $array2 = array(6, “amjad”, “aslam”, array(“x”, “y”, “z”)); ?> Output: aslam Array y

ADD/UPDATE THE VALUE OF ARRAY <?php $array2[3] = “cat”; ?> <?php echo $array2[3]; ?>

ASSOCIATIVE ARRAY “Yasir”, “last_name” => “Naeem”); ?> <?php echo $array3[“first_name”]. “ ”. $array3[“last_name”]; ?> Output: Yasir Yasir Naeem We have created a key value pair. First name is the key, Yasir is the value

<?php echo $array3[“first_name”]. “ ”. $array3[“last_name”]; ?> Output: Kashif Naeem Print readable command gives contents of an array in readable form position wise

ARRAY FUNCTIONS Count: Max value: Min value: Sort: Reverse Sort: <?php rsort($array1); print_r($array1); ?>

Implode: Implode function is used to separate the array by * to make a string. Explode: It does the reverse, it takes the string that we just created find every instance, removed the *

In array: <?php echo in_array(3, $array1); ?> This function help us to find a particular string or value in our array. It returns T/F

<?php $var1 = 3; $var2 = “cat”; ?> $var1 is set: $var2 is set: Note: isset() is very useful function, which we can use with conditional statements. Through this function we are asking, is the value of the variable is set or not. It will either return true or false.

$var1 is set: $var2 is set: Output: $var1 is set: $var2 is set: 1 This function will unset the value of a variable.

ArrayDetails $_GETStore data that is sent from URL as query string $_POSTData from FORM fields store in this array $_COOKIEData from Cookie store in this array e.g. you login to hotmail.com, you provide username and password below it there is a checkbox and when you check this checkbox your username and password stored in cookie, next time to log on you don’t need to provide username and password it retrieve from cookie. $_FILESWhen through POST method we upload any file its information stored in this array $_SESSION $_REQUESTData in $_POST, $_GET, $_COOKIE store in this array, 3 in 1. $_SERVERThis array has data that server send to client including webpage name, Server name, HTTP version, Remote IP address etc.