Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 16: PHP Types.

Slides:



Advertisements
Similar presentations
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.
Advertisements

PHP Functions Composite Types. Functions  Declaration  function functionName(paramList) {  /* code goes here */ }  paramList is comma-separated list.
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
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.
Please pick up an attendance question and submit in 5 minutes CS 1003 Lecture #3 Sept 12, 2006 Knarig Arabshian.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  Originally Personal Home Page  PHP is interpreted  PHP code is embedded.
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.
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”
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
JSON (JavaScript Object Notation).  A lightweight data-interchange format  A subset of the object literal notation of JavaScript (or ECMA-262).  A.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
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.
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
COP 3813 Intro to Internet Computing Prof. Roy Levow PHP.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
Intro to PHP – Page 1 of 43CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Intro to PHP Reading: Chapters 1.
PHP By Sergio Rodriguez By Sergio Rodriguez. PHP G PHP: Hypertext Preprocessor G Scripting language G PHP: Hypertext Preprocessor G Scripting language.
PHP Introduction Bill Jerome. PHP Hypertext Preprocessor No joke, that’s what it stands for Now very widely used for websites Only three years ago it.
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.
Serialization. Serialization is the process of converting an object into an intermediate format that can be stored (e.g. in a file or transmitted across.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
PHP PHP: Hypertext Preprocesor Personal Home Page Tools.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
PHP Arūnas Liuiza. PHP 101 What is PHP? Widely popular dynamic interpreted opensource programming language, aimed for web development Syntax is simmilar.
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables.
Comments in PHP In PHP, we use // to make a singleline comment or /* and */ to make a large comment block. Comment is a part of your PHP code that will.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Basic Data Types Numbers (integer and floating point)‏ Strings (sequences of characters)‏ Boolean values (true/false)‏
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.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
Copyright Curt Hill Variables What are they? Why do we need them?
Variables and Data Types Data (information we're going to store) – Numbers – Text – Dates What types of data can JavaScript process? How do we store it?
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Creating PHP Pages Chapter 6 PHP Variables, Constants and Operators.
PHP Workshop ‹#› أطلق إبداعك 2 أطلق إبداعك 2 مدرس معتمد من مركز زووم PHP: The Basics.
The Basics Input / Output, and Primitive Data Types.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Chapter 1 Introduction to PHP Part 1. Textbook’s Code DOWNLOADS PHP and MySQL for Dynamic Web Sites Complete Set of Scripts.
A: A: double “4” A: “34” 4.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Basic Scripting & Variables Yasar Hussain Malik - NISTE.
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.
Java Script. introduction Today’s web sites need to go much beyond HTML. browsing through a web site, to actually interact with the web site. The web.
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables Class #4.
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.
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Radoslav Georgiev Telerik Corporation
PHP using MySQL Database for Web Development (part II)
Introduction to PHP Part 1
PHP (PHP: Hypertext Preprocessor)
Scope, Objects, Strings, Numbers
PHP Intro/Overview Bird Book pages 1-11,
PHP.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 16: PHP Types

Sys Prog & Scripting - HW Univ2 PHP Types PHP provides support for the following primitive types: –boolean –integer –float –string –array –object –resource: reference to an external resource. –null

Sys Prog & Scripting - HW Univ3 <?php $boolVar = TRUE; $intVar = 7; $floatVar = 2.56; $stringVar = “Hello” ?>

Sys Prog & Scripting - HW Univ4 Boolean Type Boolean can have two values: TRUE or FALSE (case sensitive). The following is also considered as a FALSE value: 0, 0.0, “”, “0”, an array with zero elements and NULL. Everything else is considered TRUE, e.g. -1

Sys Prog & Scripting - HW Univ5 Integer Type Only signed integers are supported in PHP. Integer size is platform independent. However usual maximum value is two billions (signed). Constants PHP_INT_SIZE and PHP_INT_MAX constants hold information about integer PHP representation.

Sys Prog & Scripting - HW Univ6 Integer Type (cont'd) If an overflow occurs, the integer value will be interpreted as a float. (int) or (integer) can be used to cast to an integer value. –Usually not required as casting is done automatically.

Sys Prog & Scripting - HW Univ7 Floating Point Numbers The float type is the same as double. float size is platform independent. –Common maximum: ~1.8e308 with a precision of roughly 14 decimal. For converting to float, the value is first converted to integer and then to float (apart from when converting from string).

Sys Prog & Scripting - HW Univ8 string Type Simple way to define a string is to use a single quote. ‘ can be included by escaping it with a \ <?php Echo ‘This is a test. This is how to include a \’. But \n won’t output a new line.’ ?> This is a test. This is how to include a ’. But \n won’t output a new line. Including the string in a double quote provides support for more escape sequences.

Sys Prog & Scripting - HW Univ9 Arrays In PHP, an array is an ordered map associating values with keys –Can support many data structures: array, list, hash table, dictionary, stack and queue. The array() construct can be used to create an array composed of key => value pairs. Don’t have to be of the same type. key can be an integer or a string. value can be any PHP type.

Sys Prog & Scripting - HW Univ10 <?php $arrayVar = array( “position” => “manager”, “firstName” => “peter”, “surname” => “john”, “age” => 38) ; echo $arrayVar[“firstName”]; // peter echo $arrayVar[“age”]; // 38 ?>

Sys Prog & Scripting - HW Univ11 Another Example <?php $house = array ( “food” => array( 1 => “bread”, 2 => “vegs”, 3 => “fruits”), “people” => array( 1,2,3,4,5), “rooms” => array(“bedroom”, “livingroom”) ); ?>

Sys Prog & Scripting - HW Univ12 Classes & Objects PHP supports the object-oriented programming paradigm. A class definition contains variables (defined by var) and functions (defined by function).

Sys Prog & Scripting - HW Univ13 Class Example* items[$artnr] += $num; } *

Sys Prog & Scripting - HW Univ14 Cont. Class Example* // Take $num articles of $artnr out of th e cart function remove_item($artnr, $num) { if ($this- >items[$artnr] > $num) { $this->items[$artnr] -= $num; return true; } elseif ($this->items[$artnr] == $num) { unset($this->items[$artnr]); return true; } else { return false; } } } ?> *

Sys Prog & Scripting - HW Univ15 Creating objects Objects are instances of classes that are created using new add_item("10", 1); $another_cart = new Cart(); $another_cart->add_item("0815", 3); ?>

Sys Prog & Scripting - HW Univ16 Using the Departmental Server A PHP-enabled, departmental web server: It reads user files from /public_html And displays them under the URL / Eg: