PHP Overview CS3520 1. PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
PHP: Hypertext Processor Fred Durao
PHP (Hypertext Preprocessor) 1. PHP References From W3 Schools: PHP.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
ALBERT WAVERING BOBBY SENG. Week Whatever: PHP  Announcements/questions/complaints.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
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.
PHP MOHAMMED SHURRAB TO MISS/ RASHA ATTALLAH. What is PHP? Stands for "PHP Hypertext Preprocessor" Server-side scripting language HTML-embedded Supports.
PHP == ‘ Hypertext Preprocessor ’ Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP.
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.
PHP : Hypertext Preprocessor
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
PHP. Why should we learn web programming? No need write socket programming. - You can forget TCP/IP & OSI layers. - Web server handles socket tasks for.
INTERNET APPLICATION DEVELOPMENT For More visit:
Nael Alian Introduction to PHP
Week 9 PHP Cookies and Session Introduction to JavaScript.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Tutorial 10 Programming with JavaScript
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.
PHP - Part 2. More operators... Arithmetic and Assignment Operators e.g., using + and =  $IntA=5; $intB=8; $intC=$intA+$intB; //intC is 13  // Same.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
PHP By Sergio Rodriguez By Sergio Rodriguez. PHP G PHP: Hypertext Preprocessor G Scripting language G PHP: Hypertext Preprocessor G Scripting language.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
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. 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.
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.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Introduction to PHP Advanced Database System Lab no.1.
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.
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.
Week 4 PHP H ypertext P reprocessor Reference : Official Site :
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
הרצאה 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.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
Basic Scripting & Variables Yasar Hussain Malik - NISTE.
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,
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.
By bscshelp.com 1.  It is a group assignment.  Complete Website design Using Html and Css.  Due date: 10 th December, 2014 (Hard Deadline) 2.
PHP using MySQL Database for Web Development (part II)
CGS 3066: Web Programming and Design Spring 2017
>> Introduction to JavaScript
Introduction to Dynamic Web Programming
PHP 5 Syntax.
DBW - PHP DBW2017.
Introduction to Web programming
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
PHP Introduction.
PHP.
Web DB Programming: PHP
Basics.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Intro to PHP.
PHP an introduction.
Introduction to PHP.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

PHP Overview CS3520 1

PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files to generate client-side code end up with HTML, CSS, JavaScript, other client-side code! 2

PHP --- and its output PHP PHP Introduction This is HTML! '; ?> Output PHP Introduction This is HTML! This is PHP! 3

More PHP PHP Introduction This is HTML! <?php echo 'This is PHP! '; // prints to screen /* Here's a longer comment that spans multiple lines. */ ?> 4 PHP tags: The echo command single line comment ( // ) Multiple line comment (/* and */)

PHP file names and code End in php file extension (order.php, login.php …..) You start all PHP scripts with the. 5

Variables PHP is a loosely-typed language Do not need to declare the type of a variable Type can change throughout the program Must start with a letter, can contain numbers, no blank spaces scope (unless defined as global) is the script block it appears inside of. $x = 42; // store the value 42 in $x echo $x; // prints 42 echo $x+1; // prints 43, value of $x is still 42 $x = ‘hello!’ // type of $x can change 6

Longer example 7

Output previous example My URL is:: we/PHP/phpvariables.php Your browser is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/ (KHTML, like Gecko) Chrome/ Safari/ Your IP address is: Some html goes here.... $jake has the value 4. This is more HTML.

Constants Constants can be simply defined as follows <?php // Works as of PHP const CONSTANT = 'Hello World'; echo CONSTANT; ?> 9

Some Pre-defined variables--- see PHP documentation There are a number of pre-defined variables in PHP. See for a cmoplete listing. Below is a subset of predefined variables/arrays : $GLOBALS $_SERVER $_GET $_POST $_FILES $_COOKIE $_SESSION $_REQUEST $_ENV 10

Arrays 2 kinds Indexed are numerically indexed starting from 0. Associative arrays associate keys to their values and are indexed by their keys. The following are examples of two associative arrays, $a, $b defined followed by a numerically index array, $c. $a = array("a" => "apple", "b" => "banana"); $b = array("a" => "pear", "b" => "strawberry", "c" => "cherry"); $c = array("apple", "banana"); $a['b']; //will have the value banana $c[1]; //will have the value of banana 11

Operations – similar to C++, Java Arithmetic operators +, -, *, /, % (modulus – remainder after division) Logical AND (&&), OR (||), NOT (!) Assignment operators Shorthand for assignment operators: $x += $y equivalent to $x = $x + $y Also works with subtraction, multiplication, division, modulus, and string concatenation 12

Equality: == OR === Two “equality” operators == tests for “equality” in value but not necessarily type === tests for “identity” in value AND type == ignores the distinction between: Integers, floating point numbers, and strings containing the same numerical value Nonzero numbers and boolean TRUE Zero and boolean FALSE Empty string, the string ‘0’ and boolean FALSE Any other non-empty string and boolean TRUE 13

Strings and operations Concatenation of strings – the. operator $a = ‘hello’; $b = ‘world’; echo $a. ‘ ‘. $b. ‘!’; // prints ‘hello world!’ String functions Length: strlen() Position of substring: strpos() More on string functions: 14

Functions keyword funciton. no return type for a function parameters are defined without type In the first generic example, you see a function (myFunction) defined with n arguments and the last line of code returns a value. You would simply call this function via: $the_value = myFunction($a1,$a2,...$an); Defining the funciton <?php function myFunction($arg_1, $arg_2, /*..., */ $arg_n) { echo "Example function.\n"; return $retval; } ?> 15

Function with array as a parameter 16

Functions and arguments DEFAULT – pass by value 17

Functions and passing by reference by default arguments are passed by value to a function. The following code illustrates how to pass by reference: <?php function add_some_extra(&$string) { $string.= 'and something extra.'; } //how to call the function above $str = 'This is a string, '; add_some_extra($str); echo $str; // outputs 'This is a string, and something extra.' ?> 18

Functions with default parameter values 19