SEEM 4540 Tutorial 4 Basic PHP based on w3Schools

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
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.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Php. What is PHP? PHP is an acronym for "PHP Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on.
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.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Nael Alian Introduction to PHP
Week 9 PHP Cookies and Session Introduction to JavaScript.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
Variables, Operators and Data Types. By Shyam Gurram.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
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.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
PHP. 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.
Julian Springer Room 42 Joe Slovo.  W3 schools recommend that you have a basic understanding of HTML and of JavaScript before attempting to grasp PHP.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
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.
Introduction to PHP.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
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.
CHAPTER 6 Introduction to PHP5 Part I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
CST336, Dr. Krzysztof Pietroszek Week 2: PHP. 1.Introduction to PHP 2.Embed PHP code into an HTML web page 3.Generate (output HTML) web page using PHP.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
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.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
 Before you continue you should have a basic understanding of the following:  HTML  CSS  JavaScript.
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,
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
PHP Overview. What is PHP Widely available scripting language Free Alternative to Microsoft’s ASP Runs on the Web Server; not in the browser Example:
Unit – 3 Control structures. Condition Statements 1.If.…..else :- Has someone ever told you, "if you work hard, then you will succeed"? And what happens.
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.
CGS 3066: Web Programming and Design Spring 2016 PHP.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
1 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
A pache M ySQL P hp Robert Mudge Reference:
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
PHP using MySQL Database for Web Development (part II)
CGS 3066: Web Programming and Design Spring 2017
Session 2 Basics of PHP.
>> Fundamental Concepts in PHP
>> Introduction to JavaScript
Introduction to Dynamic Web Programming
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
DBW - PHP DBW2017.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Introduction to Web programming
PHP (PHP: Hypertext Preprocessor)
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
JavaScript Syntax and Semantics
PHP Introduction.
WEB PROGRAMMING JavaScript.
PHP.
Web DB Programming: PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Intro to PHP.
Tutorial 6 PHP & MySQL Li Xu
Tutorial 10: Programming with javascript
PHP an introduction.
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Contact PSK Technologies Pvt. Ltd IT Company Address - Plot No-780, Near Durga Temple, Katol Road Chaoni, Nagpur-13.
Presentation transcript:

SEEM 4540 Tutorial 4 Basic PHP based on w3Schools FU Zihao

PHP PHP is an acronym for "PHP: Hypertext Preprocessor" 2 PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server(we assume you have learned HTML, CSS and JavaScript) PHP is free to download and use http://www.w3schools.com/php/php_install.asp http://php.net/manual/en/install.php

What is a PHP File? 3 PHP files can contain text, HTML, CSS, JavaScript, and PHP code PHP codes are executed on the server, and the result is returned to the browser as plain HTML PHP files have extension “.php”

What Can PHP Do? 4 PHP can create, open, read, write, delete, and close files on the server PHP can collect form data PHP can send and receive cookies PHP can add, delete, modify data in your database(will be cover in the next tutorial) PHP can be used to control user-access …

① ② ③ ④ My First PHP program ① Open http://www.writephponline.com/ ② Input echo "Hello World!"; ③ Click “Run Code” ④ You made a great job! ② ③ ④

Upload to the server Our server is fully support PHP Now You can upload the PHP file to the server and view it through your browser Refer to Tutorial 1 for how to upload

Basic PHP Syntax A PHP script starts with <?php and ends with ?> 5 A PHP script starts with <?php and ends with ?> (PHP source) (Result) Note 1:A PHP file normally contains HTML tags, and some PHP scripting codes. Note 2: PHP statements end with a semicolon (;). Note 3: Keywords are NOT case-sensitive. ECHO, echo and EcHo are the same. However, all variable names are case-sensitive.($y and $Y are different variables)

PHP Variables 6 In PHP, a variable starts with the $ sign, followed by the name of the variable: $txt = "Hello world!"; $x = 5; $y = 10.5; $z=true; We can perform operations on variables and values. Then using “echo” to output the result: <?php $txt1 = "Learn PHP"; $txt2 = “seem4540"; $x = 5; $y = 4; echo "$txt1"; echo "Study PHP in $txt2<br>"; echo $x + $y; ?> Learn PHP Study PHP in seem4540 9

echo/print Statements echo and print are more or less the same. They are both used to output data to the screen. The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.

PHP Data Types Variables can store data of different types, and different data types can do different things. PHP supports the following data types: String Integer Float (floating point numbers - also called double) Boolean Array Object NULL Resource

Strings A string is a sequence of characters, like "Hello world!".

Integer An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647. Rules for integers: An integer must have at least one digit An integer must not have a decimal point An integer can be either positive or negative Integers can be specified in three formats: decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0)

Array An array stores multiple values in one single variable. In the following example $cars is an array. The PHP var_dump() function returns the data type and value:

Object An object is a data type which stores data and information on how to process that data. In PHP, an object must be explicitly declared. First we must declare a class of object. For this, we use the class keyword. A class is a structure that can contain properties and methods:

PHP Conditional Statements 7 Conditional statements are used to perform different actions based on different conditions. if (condition) { code to be executed if condition is true; } (1) switch (n) { case label1: code to be executed if n=label1; break; case label2: code to be executed if n=label2; ... default: //not necessary code to be executed if n is different from all labels; } (3) } else { code to be executed if condition is false; } (2) When using switch statement, remember to have break in your code

PHP Conditional Statements(cont’d)

PHP Loops In PHP, we have the following looping statements: 8 In PHP, we have the following looping statements: while - loops through a block of codes as long as the specified condition is true do...while - loops through a block of codes once, and then repeats the loop as long as the specified condition is true Same output result

PHP Loops(cont’d) 9  for - loops through a block of codes a specified number of times  foreach - loops through a block of codes for each element in an array (An array is a special variable, which can hold more than one value at a time.)

PHP Functions 10 A function is a block of statements that can be used repeatedly in a program. writeMsg() takes no arguments and doesn’t return values Sum($x, $y)takes two arguments and return their sum

PHP Functions (cont’d)

Some useful links for PHP 18 http://www.w3schools.com/php/default.asp (The reference of this slides) http://php.net/manual/en/install.php (PHP: Installation and Configuration) https://www.youtube.com/watch?v=iCUV3iv9xOs& list=PL00694B0DAD604DE6 (A PHP tutorial on YouTube)

Thanks!