PHP Intro/Overview Squirrel Book pages 33-87. Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a.

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 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”
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 Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
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.
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.
University of Sunderland Lecture 1 Internet Software Architectures Lecture 1: Introduction.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
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.
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.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
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.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
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.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
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.
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.
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.
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.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
PHP (Session 1) INFO 257 Supplement.
Tutorial 10 Programming with JavaScript
Web Database Programming Using PHP
PHP Introduction.
Chapter 19 JavaScript.
PHP Intro/Overview Bird Book pages 1-11,
PHP.
Web DB Programming: PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
PHP an introduction.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Intro to Programming (in JavaScript)
Presentation transcript:

PHP Intro/Overview Squirrel Book pages 33-87

Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a URL request: 2.Web server see’s that the page is.php 3.PHP Pre-processor searches the page for PHP code and executes the code. 4.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

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 servers 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”, ); print PI; // outputs 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 = ; $var = 39. “ Steps”; $var = 39 + “ Steps”;

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

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”;