Module 1 Introduction to PHP 11/30/2018 CS346 PHP.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 1-1 The Web Wizards Guide to PHP by David A. Lash.
Advertisements

1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.
PHP I.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
The Client-Server Model for the Web 1. A Web Client (usually in the form of a web browser) makes an HTTP request to a specific web server. 2. The Web Server.
The Web Warrior Guide to Web Design Technologies
CIS101 Introduction to Computing Week 05. Agenda Your questions Exam next week - Excel Introduction to the Internet & HTML Online HTML Resources Using.
1 Web Wizards Guide To PHP David Lash Chapter 1 Introduction to PHP.
CIS101 Introduction to Computing Week 05. Agenda Your questions CIS101 Survey Introduction to the Internet & HTML Online HTML Resources Using the HTML.
CIS101 Introduction to Computing
Introduction to HTML 2006 CIS101. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
Introduction to HTML 2006 INT197B. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
Introduction to HTML 2004 CIS101. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
Tutorial 1: Introduction to JavaScript JavaScript - Introductory.
Web Programming Introduction to PHP COM Objectives To understand what PHP is and how a PHP script works with a Web Browser and a Web Server To learn.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
CIS101 Introduction to Computing Week 06. Agenda Your questions Excel Exam during second hour Our status after the snow day Introduction to the Internet.
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).
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Linux Operations and Administration
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
Copyright © 2003 Pearson Education, Inc. Slide 1-1 Web Design & Development PHP.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
HTML. Principle of Programming  Interface with PC 2 English Japanese Chinese Machine Code Compiler / Interpreter C++ Perl Assembler Machine Code.
1 © Copyright 2000 Ethel Schuster The Web… in 15 minutes Ethel Schuster
Introduction to HTML. Today’s Discussion What is HTML ? What is HTML ? What is Web Page ? What is Web Page ? Web Server Web Server Web Browser Web Browser.
Introduction to JavaScript CS101 Introduction to Computing.
©John Samuel 2008 Introduction to PHP. ©John Samuel 2008 Objectives At the end of this class the student will be able to; Create and run a simple php.
PHP “Personal Home Page Hypertext Pre-processor” (a recursive acronym) Allows you to create dynamic web pages and link web pages to a database.
Chap 2 – Getting Started COMP YL Professor Mattos.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
©John Samuel 2008 Introduction to PHP Note: These slides are not included in coverage for the BIF703 final exam...
Introduction to the World Wide Web & Internet CIS 101.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
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.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 1 Using HTML to Create Web Pages.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
HTML Structure & syntax
HTML Structure & syntax
PHP Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
Module 1 Introduction to JavaScript
Introduction to HTML.
Chapter 5 Scripting Language
JavaScript is a programming language designed for Web pages.
PHP (PHP: Hypertext Preprocessor)
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Introduction to Programming the WWW I
Introduction to Scripting
Introduction to XHTML.
Developing Web-Based Applications
Chapter 5 Scripting Language
PHP / MySQL Introduction
Intro to PHP & Variables
Client side & Server side scripting
WEB PROGRAMMING JavaScript.
Web Page Concept and Design :
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
An Introduction to JavaScript
Introduction to PHP.
HTML Structure & syntax
Web Application Development Using PHP
The Web Wizard’s Guide to PHP by David A. Lash
Presentation transcript:

Module 1 Introduction to PHP 11/30/2018 CS346 PHP

PHP References General: Download, documentation Documentation: manual http://www.php.net/ Documentation: manual http://www.php.net/manual/en/ http://us2.php.net/manual/en/index.php PHP.net tutorial http://php.net/manual/en/tutorial.php W3schools tutorial http://www.w3schools.com/php/default.asp 11/30/2018 CS346 PHP

PHP functions Documented PHP functions http://us2.php.net/quickref.php You can create your own functions too 11/30/2018 CS346 PHP

Objectives What is PHP? How does a PHP script work with a Web Browser and a Web Server? What software and components you need to get started with PHP? To create and run a simple PHP script 11/30/2018 CS346 PHP

What Is PHP? PHP, PHP Hypertext Preprocessor Server-side scripting languages for creating dynamic web pages 11/30/2018 CS346 PHP

PHP advantages Advantages of Using PHP to enhance Web pages: Easy to use Simpler than Perl Open source Multiple platform. 11/30/2018 CS346 PHP

How PHP Pages are Accessed and Interpreted Client: Web browser Web server 1.Form submitted with a submit button 2.----- Action sends a request to the php file in server 3. Receive the request, find the file, and read it 4. Execute the PHP commands 5. Send the results back 6. ---- results returned as HTML file 7. Web browser renders the HTML file, displaying the results 11/30/2018 CS346 PHP

Getting Started with PHP To develop and publish PHP scripts you need: A client machine with a basic text editor and Internet connection Prepare a text file with .php extension FTP or Telnet software Upload the file.php to the server A Web server with PHP built into it Process the file.php 11/30/2018 CS346 PHP

WHH Note This means that a browser e.g. IE or Firefox on the client computer will not recognize or render a file with extension .php How do you check your PHP script before submission to server? 11/30/2018 CS346 PHP

Getting Started with PHP Set up development computer as a server Laptop contains a server and a browser environment Laptop is also set up as a Web server - WAMPserver Windows Apache, MySQL, PHP Client machine: PC, XP, editors, browsers Internet connection not needed Use copy and paste to transfer the scripts For class demos: localhost or 127.0.0.1 or cs346 server 11/30/2018 CS346 PHP

Exploring the Basic PHP Development Process The basic steps you can use to develop and publish PHP pages are: 1. Create a PHP script file and save it to a local disk Test on localhost until satisfied 2. Use FTP to copy the file to the server 3. Access your file via URL on server using a browser IE, Netscape, Opera, etc. 11/30/2018 CS346 PHP

Check PHP installation Create a simple PHP script, called phpinfo.php The PHP script starts with a <?php tag and ends with ?> Between these tags is a single PHP statement: phpinfo(); Copy the file to a directory of local server For WAMP: wamp/www Access the file with a browser http://localhost/checkphp.php 11/30/2018 CS346 PHP

11/30/2018 CS346 PHP

Checking the server set up Upload the phpinfo.php to cs346 server E.g. to huen/m00 Click on the link http://cs346.cs.uwosh.edu/huen/m00/phpinfo.php Check the various environments: Apache MySQL PHP functions variables 11/30/2018 CS346 PHP

11/30/2018 CS346 PHP

Creating a PHP Script File Create PHP script welcome.php Starts with a <?php tag and ends with ?> Between these tags is a single PHP print statement Copy the file to C:\wamp\www Access the file with http://127.0.0.1/welcome.php Demo on localhost Demo on cs346 server 11/30/2018 CS346 PHP

Similarly for other PHP scripts Upload welcome.php to huen/m00 Click on http://cs346.cs.uwosh.edu/huen/m00/welcome.php <?PHP /* welcome.php */ print ("<h1 style=\"color: blue;\">Welcome to PHP, CS346 class!</h1>"); /* Note the combination of html tags and css */ ?> 11/30/2018 CS346 PHP

Note the effect of CSS 11/30/2018 CS346 PHP

Alternative PHP Delimiters You can alternatively start your PHP scripts with the <script> tag as follows: <script language="PHP"> print ("A simple initial script"); </script> If short_open_tag enabled in its configuration file (php.ini), you can use <? and ?>. If asp_tags is enabled in the PHP configuration file, you can use <% and %> as delimiters. 11/30/2018 CS346 PHP

Proper Syntax If you have a syntax error then you have written one or more PHP statements that are grammatically incorrect in the PHP language. The print statement syntax: 11/30/2018 CS346 PHP

If syntax is wrong <?php print ( "Welcome to PHP, CS346 class!); ?> 11/30/2018 CS346 PHP

A Little About PHP's Syntax Some PHP Syntax Issues: Be careful to use quotation marks, parentheses, and brackets in pairs. Most PHP commands end with a semicolon (;). Be careful of case. PHP ignores blank spaces. 11/30/2018 CS346 PHP

Embedding PHP Statements Within HTML Documents One way to use PHP is to embed PHP scripts within HTML tags in an HTML document. Save the file first with extension html Validate the html file Change the extension to php Access the script by URL on server 11/30/2018 CS346 PHP

<html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>HTML With PHP Embedded </title> </head> <body> <p style = "font-family:sans-serif; font-size:36; color:yellow; background-color:green"> Welcome To My Page! <?PHP print ("<br /> Using PHP is not hard!"); ?> <br /> and you can learn it quickly!</p> </body> </html> 11/30/2018 CS346 PHP

When embedded1.php is accessed 11/30/2018 CS346 PHP

Using Backslash (\) to Generate HTML Tags with print() Sometimes you want to output an HTML tag that also requires double quotation marks. Use the backslash (“\”) character to signal that the double quotation marks themselves should be output: print ("<font color=\"blue\">"); The above statement would output: <font color="blue"> 11/30/2018 CS346 PHP

Using Comments with PHP Scripts Comments enable you to include descriptive text along with the PHP script. Comment lines are ignored when the script runs; they do not slow down the run-time. Comments have two common uses. Describe the overall script purpose. Describe particularly tricky script lines. 11/30/2018 CS346 PHP

Using Comments with PHP Scripts Comment Syntax - Use // standalone <?php // This is a comment ?> Can be placed on Same line as a statement: print ("A simple initial script"); //Output a line 11/30/2018 CS346 PHP

Example Script with Comments 1. <html> <head> 2. <title> Generating HTML From PHP</title> </head> 3. <body> <h1> Generating HTML From PHP</h1> 4. <?php 5. // 6. // Example script to output HTML tags 7. // 8. print ("Using PHP has <i>some advantages:</i>"); 9. print ("<ul><li>Speed</li><li>Ease of use</li> <li>Functionality</li></ul>"); //Output bullet list 10. print ("</body></html>"); 11. ?> 11/30/2018 CS346 PHP

Alternative Comment Syntax PHP allows a couple of additional ways to create comments. <?php phpinfo(); # This is a built-in function ?> Multiple line comments. /* A script that gets information about the PHP version being used. */ <? phpinfo(); ?> 11/30/2018 CS346 PHP

Summary HTML pages are static and cannot interact with users PHP is a free, open source technology that enables documents to generate dynamic content PHP script has the extension of .php PHP script may be standalone or Can be embedded in an HTML document 11/30/2018 CS346 PHP

Summary Resources needed for development: Web server with built-in PHP a client machine with a basic text editor, browser, and internet connections FTP or Telnet software to send the script to the server 11/30/2018 CS346 PHP

Summary PHP script process: Comments can be proceeded with write the PHP script file copy the script file to the Web server access the file with a Web browser Comments can be proceeded with two forward slashes (//) or # or enclosed in /* and */ 11/30/2018 CS346 PHP