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.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
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 CS URLs and web servers  Usually when you type a URL in your browser:  Your computer looks up the server's IP address using.
Server side basics.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Server side basics CS URLs and web servers  Usually when you type a URL in your browser:  Your computer looks up the server's IP address using.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
CMPT241 Web Programming Intro to PHP.
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
PHP: Introduction By Trevor Adams.
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”
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
PHP: Hypertext Processor Fred Durao
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.
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.
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
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.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
Nael Alian Introduction to PHP
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
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.
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.
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.
Introduction to Web Programming. Introduction to PHP What is PHP? What is a PHP File? What is MySQL? Why PHP? Where to Start?
Introduction to PHP.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
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.
PHP Workshop ‹#› أطلق إبداعك 2 أطلق إبداعك 2 مدرس معتمد من مركز زووم PHP: The Basics.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
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.
PHP Form Processing * referenced from
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,
CSE 154 LECTURE 14: INTRO TO PHP. URLs and web servers usually when you type a URL in your browser: your computer looks up the.
PHP-Basic By- Tanvi Raval. Pre-requisites Before you continue you should have a basic understanding of the following: 1. HTML 2. JavaScript.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP – PHP Hypertext Processor A quick overview. How is PHP used? Embedded with HTML, e.g. Not like CGI: PHP files not an executable Used with servers.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 13 Scott Marino.
PHP. What is PHP? PHP Hypertext Processor – Dynamic web development – Scripting language – Can be procedural or OOP(preferred) – PHP code can be embedded.
PHP stands for …….. “PHP Hypertext Pre-processor” and is a server-side scripting language like ASP. PHP scripts are executed on the server PHP supports.
PHP Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
PHP using MySQL Database for Web Development (part II)
PHP for Server-Side Programming
Chapter 5 Scripting Language
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Chapter 5 Scripting Language
PHP Introduction.
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Tutorial 6 PHP & MySQL Li Xu
CMPT241 Web Programming Intro to PHP.
Lecture 14: JSON and Web SERVICES
PHP an introduction.
23 PHP.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Web Application Development Using PHP
Presentation transcript:

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 server's IP address using DNS your browser connects to that IP address and requests the given file the web server software (e.g. Apache) grabs that file from the server's local file system, and sends back its contents to you some URLs actually specify programs that the web server should run, and then send their output back to you as the result: the above URL tells the server webster.cs.washington.edu to run the program quote2.php and send back its output

Server-Side web programming server-side pages are programs written using one of many web programming languages/frameworks ◦examples: PHP, Java/JSP, Ruby on Rails, ASP.NET, Python, PerlPHPJava/JSPRuby on RailsASP.NETPythonPerl the web server contains software that allows it to run those programs and send back their output each language/framework has its pros and cons ◦we will use PHP for server-side programming

Why PHP? There are many other options for server-side languages: Ruby on Rails, JSP, ASP.NET, etc. Why choose PHP? free and open source: anyone can run a PHP-enabled server free of charge free and open source compatible: supported by most popular web servers simple: lots of built-in functionality; familiar syntax available: installed on UW's servers (Dante, Webster) and most commercial web hosts well-documented: type php.net/ functionName in browser Address bar to get docs for any function

What is PHP? PHP stands for "PHP Hypertext Preprocessor" a server-side scripting language used to make web pages dynamic: provide different content depending on context interface with other services: database, , etc authenticate users process form information PHP code can be embedded in HTML code

Lifecycle of a PHP web request browser requests a.html file (static content): server just sends that file browser requests a.php file (dynamic content): server reads it, runs any script code inside it, then

Hello, World! The following contents could go into a file hello.php: <?php print "Hello, world!"; ?> PHP Hello, world! output a block or file of PHP code begins with PHP statements, function declarations, etc. appear between these endpoints

Viewing PHP output you can't view your.php page on your local hard drive; you'll either see nothing or see the PHP source code if you upload the file to a PHP-enabled web server, requesting the.php file will run the program and send you back its output

Console output: print print "text"; PHP print "Hello, World!\n"; print "Escape \"chars\" are the SAME as in Java!\n"; print "You can have line breaks in a string."; print 'A string can use "single-quotes". It\'s cool!'; PHP Hello, World! Escape "chars" are the SAME as in Java! You can have line breaks in a string. A string can use "single-quotes". It's cool! output some PHP programmers use the equivalent echo instead of print

Arithmetic Operations + - * / % = += -= *= /= %=.= many operators auto-convert types: 5 + "7" is 12

Variables $name = expression; PHP $user_name = "PinkHeartLuvr78"; $age = 16; $drinking_age = $age + 5; $this_class_rocks = TRUE; PHP names are case sensitive; separate multiple words with _ names always begin with $, on both declaration and usage implicitly declared by assignment (type is not written; a "loosely typed" language)

Types basic types: int, float, boolean, string, array, object, NULL int float boolean string array object NULL test what type a variable is with is_ type functions, e.g. is_string is_string gettype function returns a variable's type as a string (not often needed) gettype PHP converts between types automatically in many cases:converts between types automatically string → int auto-conversion on + ( "1" + 1 == 2 ) int → float auto-conversion on / ( 3 / 2 == 1.5 ) type-cast with ( type ) : $age = (int) "21";

for loop for (initialization; condition; update) { statements; } PHP for ($i = 0; $i < 10; $i++) { print "$i squared is ". $i * $i. ".\n"; } PHP

if/else statement if (condition) { statements; } else if (condition) { statements; } else { statements; } PHP can also say elseif instead of else if

while loop (same as Java) while (condition) { statements; } PHP do { statements; } while (condition); PHP break and continue keywords also behave as in Java break continue

Comments # single-line comment // single-line comment /* multi-line comment */ PHP like Java, but # is also allowed a lot of PHP code uses # comments instead of // we recommend # and will use it in our examples