PHP Intro/Overview Bird Book pages 1-11, 39-106.

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

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
IST 221 Internet Concepts and Applications Introduction to PHP.
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.
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.
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.
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 MOHAMMED SHURRAB TO MISS/ RASHA ATTALLAH. What is PHP? Stands for "PHP Hypertext Preprocessor" Server-side scripting language HTML-embedded Supports.
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 H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
University of Sunderland Lecture 1 Internet Software Architectures Lecture 1: Introduction.
Introduction to Python
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
Nael Alian Introduction to PHP
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
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.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Tutorial 10 Programming with JavaScript
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
1 CS428 Web Engineering Lecture 20 Control Structures, Loops and Pointers File Uploading Function (PHP - III)
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.
PHP PHP: Hypertext Preprocesor Personal Home Page Tools.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Introduction to PHP Advanced Database System Lab no.1.
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.
Introduction to Programming JScript Six Scripting functions Discuss functions Password Example.
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.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
1 Server versus Client-Side Programming Server-SideClient-Side.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
 A PHP script can be placed anywhere in the document.  A PHP script starts with  The default file extension for PHP files is ".php".  A PHP file normally.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
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,
IST 210: PHP Basics IST 210: Organization of Data IST2101.
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.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
>> Introduction to JavaScript
PHP (Session 1) INFO 257 Supplement.
CX Introduction to Web Programming
Tutorial 10 Programming with JavaScript
Web Database Programming Using PHP
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Introduction.
Chapter 19 JavaScript.
Introduction to JavaScript
PHP.
Web DB Programming: PHP
Basics.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Introduction to JavaScript
PHP an introduction.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Intro to Programming (in JavaScript)
Presentation transcript:

PHP Intro/Overview Bird Book pages 1-11, 39-106

Server-side Scripting Everything you need to know in one slide Web server (with PHP “plug-in”) gets a URL http://www.site.com/page.php Web server see’s that the page is .php PHP Pre-processor searches the page for PHP code and executes the code. Web server sends back the output of the PHP code, not the code itself.

PHP Basics PHP code can go anywhere in an HTML document as long as its in a PHP tag Example <h1><?php echo “Hello World”; ?></h1>

PHP Variables Variables do NOT have strict typing Unless math operations are used, variables are strings by default Variables must start with $ <?php $x = “Hello World”; echo $x; ?>

Commenting 3 Types // Comment # Comment /* Comment Comment */

Print and Echo Print can print strings print “42”; Echo is more robust than print, it can print numbers and more than one parameter, separated by commas echo 42; // This will actually print 42 $x = “is” echo “The answer ”, $x, “ ”, 42;

Single Quotes vs. Double These are the same… print “This works.”; print ‘This works also.’; This makes it easy to print quotes print “Here is a ‘single quote’ ”; print ‘Here is a “double quote” ’;

New lines The string variable $var contains a new line character  “Hello there\n sir!” $var = “Hello there sir!”; Introducing new lines breaks makes it easer to write SQL queries that work…

SQL Example $query = “ SELECT max(orderid) FROM orders WHERE custid = $ID”; If you send this query string to some database server it is important that the new line characters are in the string.

Variables in strings $x = 256 // “My computer has 256 MB ram.” $message = “My computer has $x MB ram.”; // “My computer has.” $message = “My computer has $xMB ram.”; Why?

Variables in strings $x = 256 // “My computer has.” $message = “My computer has $xMB ram.”; // “My computer has 256MB ram.” $message = “My computer has {$x}MB ram.”;

Variables in strings Using { } is very important when trying to include complex variables into other strings. $message = “Mars has a diameter of {$planets[‘Mars’][‘dia’]}.”;

Variables Integers $var1 = 10; Floats $var2 = 6.1; Boolean $var3 = true; String $var4 = “true”; $var5 = ‘true’; $var6 = ‘10’; $var7 = “6.1”;

Constants define(“PI”, 3.14159); print PI; // outputs 3.14159 Notice that constants don’t have $ Convention: Use all CAPS for constants BTW, PHP is case sensitive

Expression and Operators Same as most high-level languages $z = 3; $x = 1; $y = 5.3; $z = $x + $y; $z++; $x += $y + 10; $z = $x * 10;

String concatenation Not the same as JavaScript! $var1 = “Hello”; $var2 = “ world”; $var3 = $var1 + $var2; //This won’t work $var3 = $var1 . $var2;

Conditionals (if statements) Same as other high-level languages if ($var < 5) { print “The variable is less than 5”; }

Compound conditionals if ($x == 1) { print “x is 1”; } elseif ($x == 2) { //  Notice elseif is one word print “x is 2”; else { print “x is not 1 and not 2”;

Loops While $c = 0; while ($c < 10) { print $c . “ ”; $c++; } For for ($c = 0; $c < 10; $c++) { print $c . “ ”; }

Loops: break for ($c = 0; $c < 10; $c++) { print $c . “ ”; if ($c == 5) break; }

Type Conversion $year = 2003; // This is an integer $yearString = strval($year); // $yearString is “2003” not an integer

Type Conversion string strval(any other datatype) integer intval(any other datatype) float floatval(any other datatype)

Implicit type conversion $var = “100” + 15; $var = 100 + 15.0; $var = 39 . “ Steps”; $var = 39 + “ Steps”;

Implicit type conversion $var = “100” + 15; // $var becomes int $var = 100 + 15.0; // $var becomes float $var = 39 . “ Steps”; // $var becomes string $var = 39 + “ Steps”; // $var become int

Functions // Function definition function fname ($parameter1, $parameter2) { code; … return $returnvalue; } // Function call $x = fname(1,2);

Variable Scope (visibility) Same as Java Same as C++ function fun($x) { $temp = $x + 1; } fun(5); print “temp is: $temp”;