IST 210: PHP Basics IST 210: Organization of Data IST2101.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Introducing JavaScript
Introduction to JavaScript
George Mason University
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
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.
Python and Web Programming
Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Server side basics.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
Web Page A page displayed by the browser. Website Collection of multiple web pages Web Browser: A software that displays web pages on client computer.
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.
ITM352 PHP and Dynamic Web Pages: Server Side Processing.
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.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
Introduction to Python
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
Nael Alian Introduction to PHP
Writing Web Pages By Shyam Gurram. Agenda Writing Web Pages Delimiting PHP Program Units. Displaying Output to Web Pages Putting Comments in PHP Programs.
Week 9 PHP Cookies and Session Introduction to JavaScript.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
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.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
PHP and JavaScript Nov. 26, 2013 Kyung Eun Park Computer and Creativity (COSC109) Towson University.
HTML Table and PHP Array
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
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.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Strings, output, quotes and comments
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.
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.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
HTML BASIC IST 210: Organization of Data IST210 1.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
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
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
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 ARRAY AND HTML TABLE IST 210 Organization of Data IST210 1.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
HTML Basic IST 210: Organization of Data IST2101.
Tutorial 10 Programming with JavaScript
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Intro to PHP & Variables
WEB PROGRAMMING JavaScript.
An Introduction to JavaScript
Presentation transcript:

IST 210: PHP Basics IST 210: Organization of Data IST2101

Previous Classes Review IST2102 HTML Basics

How A Web Server Works IST Find the IP address of the server my.up.ist.psu.edu Send the request to the server HelloWorld.html Hello World! Get file: helloworld.html From folder zul17 Return to user User Web Server

Problems with HTML Static pages –Cannot provide dynamic contents based on user preferences and interest Users often need different things in different conditions –Google –Facebook –ANGEL, webmail IST2104

Dynamic Web Contents Through scripts (e.g., PHP) –Programs that can generate dynamic HTML results Two types of scripts –Client side: running inside a browser –Server side: running inside a web server IST2105

Hello World in PHP IST <?php echo "Hello World!"; ?> Hello World!

Dynamic PHP Example: Show Date IST Today is: 08/27/12

How It Works: More Details When a browser requests an HTML file, the HTTP server returns the file When a browser requests an PHP file –The web server passes the request to a PHP interpreter –The PHP interpreter reads the PHP file, line by line, and executes the scripts in the file –Finally, the executed result is returned to the web server, which delivers HTML contents to the browser IST2108

PHP Must Work Through a Web Server Check the date.php file in the webpage Click the file in the folder and see what happens Try “View Page Source” DON’T CLICK ON PHP PAGE DIRECTLY!!! PUT PHP PAGE ON WEBSPACE AND VISIT THROUGH WEB BROWSER!!! IST2109

Differences Between PHP and HTML Which language is used for display format? –HTML Which language is programming language? –PHP Which runs on the client side (the system on which the page is being viewed) ? –HTML Which runs on the server side (the system from which the page comes)? –PHP IST21010

PHP and HTML HTML –is a language used to describe to a browser how to display text and other objects in a browser window –NOT a programming language –works on a client computer (the system on which the page is being viewed PHP –is a scripting language, and can be used to create HTML page –runs on the server (the system from which the page comes) –is a full-fledged programming language programming languages: C, C++, C#, JAVA, Python IST21011

About PHP Created in 1994 by Rasmu Lerdorf A simple set of Common Gateway Interface binaries written in the C programming language Originally used to track visits to his online resume “Personal Home Page tools” PHP is used as the server-side programming language on 75% of all Web sites –E.G. Facebook, Wikipedia IST21012

PHP – Getting started PHP code segments are mixed with HTML source Escaping from HTML (To tell PHP processor: this is PHP code) A PHP parser starts to execute codes when it encounters a start tag The parser does not process non-PHP code Two options indicating the embedded PHP codes IST21013 ( ) …

PHP – Getting Started Step 1. Open a NotePad++ Step 2. Input codes Step 3. Save it to “helloworld.php” to your webspace Step 4. Open a web browser, and visit – D/helloworld.php D/helloworld.php IST21014 <?php echo "Hello World!"; ?> Try it

echo IST21015 <?php echo "Hello World!"; ?> echo means “print it to html” Double quotes pair “” define a string Semicolon ; means the end of a sentence

echo IST21016 <?php echo "Hello World!"; ?> HTML is not a strict language. It is OK to only have PHP part.

echo IST21017 <?php echo " Hello World! "; ?> Try it

echo: Exercise 1 IST21018 <?php echo " Hello World! "; ?> Think How to modify codes to get the output on the right ? Penn State in bold

echo: Exercise 2 IST21019 How to modify codes to get the output on the right ? A break after “Penn State” Red in color red <?php echo " Hello World! "; ?> Think

echo IST21020 This is HTML part. Hello world in HTML. <?php echo "Hello World in PHP! "; ?> Back to HTML again! <?php echo "Hello World in PHP again!"; ?> Try it Multiple PHP segments

echo echo — Output one or more strings –String is defined in a pair of " " –String concatenate using. IST21021 <?php echo "Welcome "." "."Hello World"; ?> Try it

echo IST21022 echo "Welcome "." "."Hello World"; echo "Welcome Hello World"; echo "Welcome"; echo " "; echo "Hello World";

Variables Data types –Similar to C++ or Java Int, Float, Boolean, String Array (next class), Object (not covered in our class) Variables: a symbol or name that stands for a value –PHP variables start with $ –You can use variables without defining the type $x = 5; $pi = 3.14; $name = "George"; –Name your variables in meaningful ways $s = "matrix" vs. $servername = “matrix” –Case sensitive! More data types – IST21023

Variables IST21024 <?php $x = 1; //integer $y = 2.2; //float $z = "hello"; //string echo "x is $x"; echo "x is ".$x; ?> 1.Create a test.php in your webspace 2.Input following codes 3.Visit through web browser Try it $x can be put insides quotes or outside quotes. When $x is outside of quotes, remember to use. to concatenate two strings

Variables: Exercise 1 IST21025 <?php $x = 1; //integer $y = 2.2; //float $z = “hello”; //string echo "x is $x"; ?> Think How to modify codes to get the output on the right?

Variables: Exercise 2 IST21026 <?php $x = 1; //integer $y = 2.2; //float $z = “hello”; //string echo "z is $z"; ?> Think How to modify codes to get the output on the right (with quotes on hello)?

Variables: Exercise 3 IST21027 <?php $name = "John"; echo "My name is $Name."; ?> Debug Name is not shown. Where is the bug?

Variables: Exercise 4 IST21028 <?php $x = "Penn State"; echo "I love $x"; ?> Think How to make the string in bold?

Expressions Any legal combination of symbols that represents a value –Each programming language and application has its own rules for what is legal and illegal Every expression consists of at least one operand and can have one or more operators –Operands are values –Operators are symbols that represent particular actions Examples –5+3 –$x*$y –$x > $y –$x <> $y –$x == $y More: – IST21029 A==B: boolean result, true or false A=B: assign variable B’s value to variable A A very common mistake: if (x = 1) then …  This is always true!

Functions IST Create a date.php in your webspace 2. Visit it through web browser Try it

Functions echo — Output one or more strings –String is defined in a pair of " " –String concatenate using. IST21031 <?php echo "A: What is the day today? "; echo "B: ".date("l, F d Y")." "; echo "A: Not Friday yet?! " ?> Try it

Functions IST21032 <?php <?php echo "Today is: ".date("m/d/y").” ”; echo “A random number in [1,10]”.rand(1,10).” ”; $name = "John"; echo "The length of string \" $name \" is ".strlen($name); ?> ?> More string functions More math functions

Learn more about PHP Reference websites – – Learn by yourself – Learn from experience –Try it yourself! –Try different ways to write the codes. –Learn from debugging Learn from examples –Search “php echo” on google – –Learn from the example IST21033