10/5/2015CS346 PHP1 Module 1 Introduction to 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.
Adding Dynamic Content to your Web Site
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
Server-Side vs. Client-Side Scripting Languages
1 Web Wizards Guide To PHP David Lash Chapter 1 Introduction to PHP.
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.
Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
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.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
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.
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.
Linux Operations and Administration
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
INTRODUCTION TO WEB DATABASE PROGRAMMING
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Copyright © 2003 Pearson Education, Inc. Slide 1-1 Web Design & Development PHP.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
Writing Web Pages By Shyam Gurram. Agenda Writing Web Pages Delimiting PHP Program Units. Displaying Output to Web Pages Putting Comments in PHP Programs.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic.
Tutorial 10 Programming with JavaScript
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
1 Welcome to CSC 301 Web Programming Charles Frank.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
JavaScript Tutorial 1 - Introduction to JavaScript1 Tutorial 1 Introduction to JavaScript Section A – Programming, HTML, and JavaScript.
Introduction to JavaScript CS101 Introduction to Computing.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
©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.
WHAT IS SERVER SIDE SCRIPTING? Server-side scripting is a web server technology in which a user's request is verified by running a script directly on the.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Chap 2 – Getting Started COMP YL Professor Mattos.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
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.
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.
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,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
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.
Introduction to Programming the WWW I
PHP / MySQL Introduction
WEB PROGRAMMING JavaScript.
Module 1 Introduction to PHP 11/30/2018 CS346 PHP.
The Web Wizard’s Guide to PHP by David A. Lash
Presentation transcript:

10/5/2015CS346 PHP1 Module 1 Introduction to PHP

PHP References  General: Download, documentation  Documentation: manual  PHP.net tutorial  W3schools tutorial 10/5/2015CS346 PHP2

PHP functions  Documented PHP functions  You can create your own functions too 10/5/2015CS346 PHP3

10/5/2015CS346 PHP4 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

10/5/2015CS346 PHP5 What Is PHP?  PHP, PHP Hypertext Preprocessor Server-side scripting languages for creating dynamic web pages Server-side scripting languages for creating dynamic web pages

10/5/2015CS346 PHP6 PHP advantages Advantages of Using PHP to enhance Web pages: Easy to use Easy to use Simpler than Perl Simpler than Perl Open source Open source Multiple platform. Multiple platform.

10/5/2015CS346 PHP7 How PHP Pages are Accessed and Interpreted Client: Web browserWeb server 1.Form submitted with a submit button  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

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

10/5/2015CS346 PHP9 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?

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

10/5/2015CS346 PHP11 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 satisfiedTest 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.IE, Netscape, Opera, etc.

10/5/2015CS346 PHP12 Check PHP installation  Create a simple PHP script, called phpinfo.php The PHP script starts with a The PHP script starts with a Between these tags is a single PHP statement: phpinfo(); Between these tags is a single PHP statement: phpinfo();  Copy the file to a directory of local server For WAMP: wamp/www For WAMP: wamp/www  Access the file with a browser 

10/5/2015CS346 PHP13

Checking the server set up  Upload the phpinfo.php to cs346 server E.g. to huen/m00 E.g. to huen/m00  Click on the link   Check the various environments: Apache Apache MySQL MySQL PHP functions PHP functions variables variables 10/5/2015CS346 PHP14

10/5/2015CS346 PHP15

10/5/2015CS346 PHP16 Creating a PHP Script File  Create PHP script welcome.php Starts with a Starts with a Between these tags is a single PHP print statement Between these tags is a single PHP print statement  Copy the file to C:\wamp\www  Access the file with  Demo on localhost  Demo on cs346 server

Similarly for other PHP scripts  Upload welcome.php to huen/m00  Click on  /5/2015CS346 PHP17 <?PHP /* welcome.php */ print (" Welcome to PHP, CS346 class! "); /* Note the combination of html tags and css */ ?>

10/5/2015CS346 PHP18 Note the effect of CSS

10/5/2015CS346 PHP19 Alternative PHP Delimiters  You can alternatively start your PHP scripts with the tag as follows: print ("A simple initial script"); </script>  If short_open_tag enabled in its configuration file (php.ini), you can use.  If asp_tags is enabled in the PHP configuration file, you can use as delimiters.

10/5/2015CS346 PHP20 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:

10/5/2015CS346 PHP21 If syntax is wrong <?php print ( "Welcome to PHP, CS346 class!); print ( "Welcome to PHP, CS346 class!);?>

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

10/5/2015CS346 PHP23 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

10/5/2015CS346 PHP24 <head> HTML With PHP Embedded HTML With PHP Embedded </head><body> Welcome To My Page! Welcome To My Page! <?PHP <?PHP print (" Using PHP is not hard!"); print (" Using PHP is not hard!"); ?> ?> and you can learn it quickly! and you can learn it quickly! </body></html>

10/5/2015CS346 PHP25 When embedded1.php is accessed

10/5/2015CS346 PHP26 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 (" "); Use the backslash (“\”) character to signal that the double quotation marks themselves should be output: print (" "); The above statement would output: The above statement would output:

10/5/2015CS346 PHP27 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. Comment lines are ignored when the script runs; they do not slow down the run-time. Comments have two common uses. Comments have two common uses. Describe the overall script purpose.Describe the overall script purpose. Describe particularly tricky script lines.Describe particularly tricky script lines.

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

10/5/2015CS346 PHP29 Example Script with Comments Generating HTML From PHP 2. Generating HTML From PHP 3. Generating HTML From PHP 3. Generating HTML From PHP 4. <?php 5. // 6. // Example script to output HTML tags 7. // 8. print ("Using PHP has some advantages: "); 9. print (" Speed Ease of use 9. print (" Speed Ease of use Functionality "); //Output bullet list Functionality "); //Output bullet list 10. print (" "); 11. ?>

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

10/5/2015CS346 PHP31 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

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

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