IST 210: PHP BASICS IST 210: Organization of Data IST210 1.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Introduction to JavaScript
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
BY: ALBERTO CABEZAS 4/19/2010. INTRODUCTION: PHP is considered today as one of the most famous scripting languages. PHP is widely used as a general purpose.
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.
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.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
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.
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.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
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.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
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
Week 9 PHP Cookies and Session Introduction to JavaScript.
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.
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.
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.
Exercise 1: IF/ELSE Step 1: Open NotePad++ and create “number.php” in your webspace Step 2: Write codes to do the following 1.Generate a random number.
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.
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.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
HTML Basic IST 210: Organization of Data IST2101.
PHP Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
Tutorial 10 Programming with JavaScript
CHAPTER 5 SERVER SIDE SCRIPTING
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
PHP Introduction.
Intro to PHP & Variables
WEB PROGRAMMING JavaScript.
An Introduction to JavaScript
Presentation transcript:

IST 210: PHP BASICS IST 210: Organization of Data IST210 1

Previous Classes Review IST210 2 HTML Basics

Place Your Page on Web Step 1. Go to your webspace folder Open any folder. On the left-hand side, expand Computer, click on “IST UP Webspace”. Step 2. Place your helloWorld.html in the webspace folder Step 3. Open a browser, visit my.up.ist.psu.edu/YourPSUID/helloWorld.html IST210 3 If I put helloWorld.html file on my desktop, does this work?

IST 210: PHP BASICS IST 210: Organization of Data IST210 4

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 IST210 6

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 IST210 7

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 IST210 10

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 IST210 11

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 IST210 12

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: Originally: Personal Home Page; Now: Hypertext Preprocessor PHP is used as the server-side programming language on 75% of all Web sites E.G. Facebook, Wikipedia IST210 13

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 IST ( ) …

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 helloworld.php helloworld.php IST <?php echo "Hello World!"; ?> Try it

PHP Must Work Through a Web Server Find the helloworld.php file in your webspace Double Click the file in the folder and see what happens Now visit through your web browser: What happened? PHP must work thru a web server! Try “View Page Source” IST210 16

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

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

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

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

echo: Exercise 1 Answer IST <?php echo "Welcome to Penn State "; ?> How to modify codes to get the output on the right ? Penn State in bold

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

echo: Exercise 2 Answer IST <?php echo "Welcome to Penn State "; echo "I like red "; ?> How to modify codes to get the output on the right ? A break after “Penn State” Red in color red

echo IST 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. IST <?php echo "Welcome "." "."Hello World"; ?> Try it

echo IST 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 IST210 27

Variables IST <?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 IST <?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 1 Answer IST <?php $x = 1; //integer $y = 2.2; //float $z = "hello"; //string echo "x is $x "; echo "y is $y "; echo "z is $z "; ?> How to modify codes to get the output on the right?

Variables: Exercise 2 IST <?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?

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

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

Variables: Exercise 3 Answer IST <?php $name = "John"; echo "My name is $name."; ?> Variable name is sensitive. Should be $name not $Name

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

Variables: Exercise 4 Answer IST <?php $x = "Penn State"; echo "I love $x "; ?>

Variables: Exercise 1 IST <?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 IST <?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 IST <?php $name = "John"; echo "My name is $Name."; ?> Debug Name is not shown. Where is the bug?

Variables: Exercise 4 IST <?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: IST 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 IST Create a date.php in your webspace 2. Visit it through web browser Try it

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

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

Functions IST <?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 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 IST210 47

Reminder Assignment 2 due on Monday Sept 14 th 11:59PM! IST210 48