Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.

Slides:



Advertisements
Similar presentations
» PHP arrays are lists of values stored in key-value pairs. » Uses of arrays: Many built-in PHP environment variables. Database functions use arrays.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
PHP (2) – Functions, Arrays, Databases, and sessions.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic PHP.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
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.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
PHP: Introduction By Trevor Adams.
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.
PHP: Hypertext Processor Fred Durao
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.
NMD202 Web Scripting Week1. Contact Information – Lecturer is a part time member of staff. Students are encouraged to use.
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.
PHP : Hypertext Preprocessor
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.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
INTERNET APPLICATION DEVELOPMENT For More visit:
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
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.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
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 - 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 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 PHP: Hypertext Preprocesor Personal Home Page Tools.
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
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.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
PHP - 1h. How it works Client requests document Server loads document in memory Server processes document with relevant module (PHP) Server sends XHTML.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
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.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Chapter 1 Introduction to PHP Part 1. Textbook’s Code DOWNLOADS PHP and MySQL for Dynamic Web Sites Complete Set of Scripts.
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.
NMD202 Web Scripting Week2. Web site
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
C is a high level language (HLL)
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.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
Introduction to Dynamic Web Programming
Introduction to PHP Part 1
Web Database Programming Using PHP
PHP Intro/Overview Bird Book pages 1-11,
PHP.
Web DB Programming: PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Tutorial 6 PHP & MySQL Li Xu
Programming PHP on the Server
PHP an introduction.
23 PHP.
Presentation transcript:

Just a Little PHP Programming PHP on the Server

Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control Statements Functions and Subroutines Macros and Preprocessor Commands I/O Statements Libraries External Tools (Compiler, debugger etc)

PHP like JavaScript is Embedded in Web Pages The difference is that a PHP file is executed by the Server BEFORE being sent to the client. Just like CGI. <?php //Your PHP goes here ?>

Comments // This is a single line comment /* This is a multiline comment just like C */

Data Types PHP is a weakly typed language. Any variable can be any data type The available data types are: boolean number (integer and float) string array object

Variable Names To declare a scalar variable just use it. Variable names begin with a $, ie: $x=7; echo $counter;

Constants Numeric: E x2A String: “Hello” ‘Nice Day’ Bob define(“MYCONSTANT”, 42); echo MYCONSTANT If a constant is not defined it stands for itself, ie: Bob. Otherwise it stands for its value. Constants should be ALLCAPS and do not use a $ before the name

Creating an Array $list[0] = 17; //This creates an array $list = array(1,2,3 4,5); //creates an indexed array $list = array(“Smith” => “Carpenter, “Jones”=> “Technician”, “Rajiv” => “Manager”); //Associative array $n=sizeof($list);

Operators Arithmetic: Regular C style operators = + - * / % += -= *= /= Relational: == != <> > = <= Note: “4” == 4 is True String: “a”. $b $a.=$b; Logical: && || !

Web Page Output echo “The size of my array is: “. $n; print “Hello World: “. $n; printf “There are %4d items in my array, %s\n”, $n, $name; printf uses the same format codes that C uses: %d (integer) %f (float) %x (hex) %s (string) (There is one new format code: %b - binary)

if/then/else if ($price 20) { printf “%10.2f is a reasonable price ”, $price; $total+=$price; } else echo “Try again!”;

Simple for loops for($i=1;$i<10;$i++) { $sum+=$i; echo “Running total is: “ + $sum + “ ”; } echo “Final total is: “ $sum;

Looping Through Associative Arrays foreach( $array as $key => $value) { echo “Key: “. $key echo “Value: “. $value; } Note: Associative Arrays and Indexed Arrays are the same thing. The key values for an indexed array are: 0, 1,

Functions in PHP function myFunction($arg1, $arg2, $arg3) { //Do some calculation ie: $result= ($arg1 + $arg2) % $arg3; return $result; }

Including a library of functions include (“myLibraryFile.php”); require(“myLibrary.php”); require_once(“myLibrary.php”); Use any of:

Important PHP VariablesPurpose $_GET, $_POST, $_COOKIE $_REQUEST Data sent between client and server. $_REQUEST includes all 3 $REMOTE_ADDRIP of the client $HTTP_REFERERPrevious Web Page $REQUEST_TIMEWhen page was requested (EPOCH time) $HTTP_USER_AGENTBrowser Info $SCRIPT_FILENAMECurrent PHP script file

SQL Functions MYSQL FUNCTION CALLEXPLANATION mysql_error()Report on last error mysql_connect(host,user, pass)connects to database; returns a connection to the database mysql_selectdb(dbName)use specified schema $result=mysql_query(stmt)runs stmt against the database returns 0 to n rows for SELECT returns number of rows affected for INSERT, UPDATE or DELETE $row=mysql_fetch_array($resu lt) creates an associative array using column names as keys mysql_close($con)closes the database connection

SQL Functions Some PHP FunctionsEXPLANATION date(‘r’)The current date as a string time()current time die(message)print out a message and quit include(‘fileName’) require_once(‘fileName’); include an external PHP file – allows shared code and libraries

THE END