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.

Slides:



Advertisements
Similar presentations
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Advertisements

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.
PHP Introduction.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Chapter 2 Data Types, Declarations, and Displays
Guide To UNIX Using Linux Third Edition
Chapter 2: Introduction to C++.
ASP.NET Programming with C# and SQL Server First Edition
JavaScript, Third Edition
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.
Lecture 2 Introduction to PHP MIS 3501, Spring 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University January 30, 2014.
PHP MOHAMMED SHURRAB TO MISS/ RASHA ATTALLAH. What is PHP? Stands for "PHP Hypertext Preprocessor" Server-side scripting language HTML-embedded Supports.
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
Java Building Elements Lecture 2 Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
INTERNET APPLICATION DEVELOPMENT For More visit:
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
2440: 211 Interactive Web Programming Expressions & Operators.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
1 Working with Data Types and Operators. 2 Using Variables and Constants The values stored in computer memory are called variables The values, or data,
CPS120: Introduction to Computer Science
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Open Source Software Unit – 3 Presented By Mr. R.Aravindhan.
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Introduction to PHP Advanced Database System Lab no.1.
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.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
PHP Programming with MySQL Slide 3-1 CHAPTER 3 Working with Data Types and Operators.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Basic Scripting & Variables Yasar Hussain Malik - NISTE.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
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 Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
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,
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.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
PHP using MySQL Database for Web Development (part II)
Chapter 2: Introduction to C++
Web Technologies PHP 5 Basic Language.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Introduction.
Chapter 19 JavaScript.
JavaScript an introduction.
Web Systems Development (CSC-215)
2.1 Parts of a C++ Program.
Chapter 8 JavaScript: Control Statements, Part 2
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Chapter 2: Introduction to C++.
Tutorial 10: Programming with javascript
PHP an introduction.
23 PHP.
Chapter 2 Primitive Data Types and Operations
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

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 to the PHP interpreter The PHP interpreter processes the page, communicating with file systems, databases, and servers as necessary Finally delivers a web page to the web server, which is served to the browser

Syntax PHP code can be inserted into HTML files using a special set of tags Standard tags <?php... code ?> Short tags <?... code ?> Script tags... code ASP tags <%... code %> asp_tags in php.ini Short, script and ASP tags are considered deprecated and their usage is strongly discouraged

Comments PHP comments Commenting is important in any programming language to document the behaviour of the code. Otherwise maintenance becomes difficult. Supports C, C++ and Unix shell style (Perl style) comments //one line C++ style comment /* this is a multi-line comment. Yet another line of comment */ # one line shell style comment d1comments.php source d1comments.php

Datatypes [1] Various types of datatypes in PHP Scalar Contains only one value at a time PHP supports four scalar datatypes boolean int float string Compound array object Special types resource null

Datatypes [2] Scalar data types Numeric values integer  Used to represent signed integers  Can use decimal, octal and hexadecimal notations  Start with 0 for octal (base 8) and 0x for hexadecimal (base 16) notation float  Are numbers that have a fractional component  Two different notations to express them  Decimal (e.g. 0.12, )  Exponential (e.g. 2E7, 1.2e2) String Series of characters within PHP, each character is represented by a single byte Upto PHP 5, no support for multi- byte character sets PHP does not impose any limit on length of strings 3 ways of string output Boolean They hold only one of two possible values true or false Any integer other than 0 is cast to TRUE TRUE & FALSE are case insensitive, though the all capitals representation is widely used

Datatypes [3] Compound Essentially container(s) for multiple data elements / data and code Array  Containers of multiple ordered data elements  Can be used to store and retrieve any other data type, including numbers, boolean values, strings, objects and even arrays  Covered in more detail in a subsequent section Object Objects are containers of data and code They allow a cohesive combination of data and code They are the fundamental blocks of OOP (Object Oriented Programming)

Datatypes [4] Special datatypes Null A null variable is special, as it has no type and no value NULL is not the same as integer zero nor the zero length string (both have types) A variable is considered NULL if it is assigned the constant NULL, or it is not set to any value as yet or it has been unset (using unset()). Resource Resources are special variables.  They hold references to external resources (some sort of operating system resource such as an open file or database connection ) Resources are created by using special functions, depending on the type of the resource Functions is_resource() and get_resource_type() are commonly used with resources

Constants & variables Constants Are identifiers for immutable values (viz., the value cannot be changed in the course of execution of the script) Constants are created using the define() function and are by convention all in uppercase letters Constants can be accessed from anywhere on the page No need to use $ in front of the constant name, as in the case of a variable Variables Are temporary storage containers In PHP, a variable can contain any type of data. PHP is loosely typed, meaning it will change the type of a variable as needed Variables are identified by $ sign, followed by an identifier name isset() is used to determine whether a variable exists or not Other relevant functions are unset() and empty() d1datatype.php source d1datatype.php

Operators Assignment For assigning data to variables (assignment with operation as well) Arithmetic For performing basic mathematic functions String For joining two or more strings Comparison For comparing two values (i.e. pieces of data). Various rules govern the comparison process Logical For performing logical operations on boolean values Bit-wise For manipulating bits using boolean algebra Error control For suppressing errors Execution For executing system commands Increment / Decrement For incrementing / decrementing numeric values Type For identifying operators d1operator.php source d1operator.php

Control structures If Normal, alternate, short switch while do-while for continue break foreach return require Include d1controlstruct.php source d1controlstruct.php

if statement conditional If (expression) true_statement; else false_statement; if (expression1) { } elseif (expression2) { // Note that the space between else and if is optional } else { } alternate syntax opening brace { = : closing brace } = endif; if (expression1): statements; elseif (expression2): statements; endif; Ternary conditional operator $variable = (expression) ? true_expression: false_expression;