PHP Programming with MySQL Slide 2-1 CHAPTER 2 Getting Started with PHP.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
The Web Warrior Guide to Web Design Technologies
Apache Installation by Jack Davis. Web Servers The Apache HTTP Server is the most widely used web server on the Internet. Apache is fast, free, and full-featured.
Objectives Install and configure a Web server
PHP Introduction.
1 Chapter 12 Working With Access 2000 on the Internet.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Web Wizards Guide To PHP David Lash Chapter 1 Introduction to PHP.
Tutorial 10 Programming with JavaScript
Module 6 Windows 2000 Professional 6.1 Installation 6.2 Administration/User Interface 6.3 User Accounts 6.4 Managing the File System 6.5 Services.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Tutorial 1: Introduction to JavaScript JavaScript - Introductory.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Introduction to scripting
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Linux Operations and Administration
Lecture 2 Introduction to PHP MIS 3501, Spring 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University January 30, 2014.
9.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKPRO GUIDE Chapter 1: Introduction Dr. Mogeeb Moslehh Date: 15 March 2014 Saturday ( pm) SE3 Lecture Room:
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
CIM6400 CTNW (04/05) 1 CIM6400 CTNW Lesson 6 – More on Windows 2000.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
BMC3183 Advance Web Programming Programming Session 2013/2014.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
Chapter 8 Cookies And Security JavaScript, Third Edition.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Chapter 1 Creating a Dreamweaver Web Page and Local Site
Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
1 Session 1: Introduction to PHP & MySQL iNET Academy Open Source Web Development.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
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.
Apache, MySQL and PHP Installation and Configuration Chapter 2 MySQL Installation and Configuration.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 JavaScript in Context. Server-Side 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.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
©John Samuel 2008 Introduction to PHP Note: These slides are not included in coverage for the BIF703 final exam...
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Hands-On Microsoft Windows Server 2008 Chapter 5 Configuring Windows Server 2008 Printing.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Web Server Administration Chapter 6 Configuring a Web Server.
PHP using MySQL Database for Web Development (part II)
Module 1 Introduction to JavaScript
Introduction to Scripting
Chapter 2 Getting Started with PHP PHP Programming with MySQL
WEB PROGRAMMING JavaScript.
PHP.
Objectives Install and configure a Web server
Tutorial 10 Programming with JavaScript
An Introduction to JavaScript
JavaScript: Introduction to Scripting
Presentation transcript:

PHP Programming with MySQL Slide 2-1 CHAPTER 2 Getting Started with PHP

PHP Programming with MySQL Slide 2-2 Objectives Install and configure a Web server Install and configure PHP Install and configure MySQL Create basic PHP scripts

PHP Programming with MySQL Slide 2-3 Understanding Installations Binary format (or binaries) refer to compiled files, such as executable installation programs Source code is the original programming code in which an application was written Source code must be compiled, or processed, and assembled into an executable format before it is used Compiled programs only need to be recompiled when their code changes

PHP Programming with MySQL Slide 2-4 Installing and Configuring a Web Server Apache is the most popular Web server software used on the Internet Microsoft IIS for Windows is the second most popular server software In Windows, a service refers to a program that performs a specific function to support other programs

PHP Programming with MySQL Slide 2-5 Installing and Running Apache on UNIX and Linux 1. Go to 2. Run the gunzip command: gunzip httpd tar.gz 3. Run the tar command: tar xvf httpd tar 4. Change to the http directory: cd httpd Run the configure command:./configure

PHP Programming with MySQL Slide 2-6 Installing and Running Apache on UNIX and Linux 6. Compile the Apache source code with the make command 7. Run the make install command in the httpd directory 8. Start, stop, and restart Apache using the apachectl control script

PHP Programming with MySQL Slide 2-7 Installing and Running Apache on Windows 1. Go to 2. Download the MSI Installer (installation file) for Win-32 Binary. 3. Navigate to the installation file and from the Welcome screen, click Next 4. Accept the terms of the License Agreement, click Next 5. Read the contents of the Read This First screen, click Next

PHP Programming with MySQL Slide 2-8 Installing and Running Apache on Windows 6. Accept the default values, click Next 7. Select a Typical installation, click Next 8. Accept the default Destination Folder directory, click Next 9. Click Back to make changes or click Install to finish 10. Click Finish

PHP Programming with MySQL Slide 2-9 Installing and Running Internet Information Services on Windows 1. Open the Control Panel from the Start menu 2. If using Windows XP, select Switch to Classic View 3. Select the Add or Remove Programs icon 4. Click Add/Remove Windows Components 5. Click the check box next to Internet Information Services (IIS), click Next

PHP Programming with MySQL Slide 2-10 Installing and Running IIS on Windows 6. After the installation is complete, click Finish 7. If prompted, restart Windows otherwise close the Control Panel

PHP Programming with MySQL Slide 2-11 Testing Your Web Server 1. Open your Web browser 2. Type in the Address box, click Enter Figure 2-2 Apache’s default Web page

PHP Programming with MySQL Slide 2-12 Testing Your Web Server 3. Type in the Address box, click Enter Figure 2-3 Web page informing you that IIS is running

PHP Programming with MySQL Slide 2-13 Configuring Apache To configure ports and other settings you must edit the httpd.conf file For UNIX/Linux  /usr/local/apache2/conf For Windows  C:\Program Files\Apache Group\Apache2\conf Lines that begin with the pound sign (#) are informational comments Lines without pound signs contain directives

PHP Programming with MySQL Slide 2-14 Configuring Apache Figure 2-4 httpd.conf

PHP Programming with MySQL Slide 2-15 Configuring Apache Directives define information about how a program should be configured The DocumentRoot directive identifies the default directory from where Apache serves Web pages The Alias directive identifies other directories that Apache can use to serve Web pages

PHP Programming with MySQL Slide 2-16 Configuring IIS Figure 2-5 Default Web Site Properties dialog box

PHP Programming with MySQL Slide 2-17 Installing PHP on UNIX and Linux Systems Running Apache 1. Go to 2. Run the gunzip command: gunzip php tar.gz 3. Run the tar command: tar xvf php tar 4. Change to the php directory: cd php Run the configure command:./configure

PHP Programming with MySQL Slide 2-18 Installing PHP on UNIX and Linux Systems Running Apache 6. Compile the PHP source code with the make command 7. Run the make install command in the php directory 8. Specify which configuration file you want to use with PHP: cp php.ini-dist /usr/local/lib/php.ini

PHP Programming with MySQL Slide 2-19 Installing PHP Windows Running Apache or IIS 1. Go to and download the latest Windows binary installer 2. Navigate to the installation file and from the Welcome screen, click Next 3. In the License Agreement screen, click I Agree 4. Accept the default destination location, click Next

PHP Programming with MySQL Slide 2-20 Installing PHP Windows Running Apache or IIS 6. In the Server Type screen, select the type of Web server that you want to use with PHP, click Next 7. From the “Choose Items to Install” screen, select the modules to be installed. 8. In the Ready to Install screen, click Install to begin installation

PHP Programming with MySQL Slide 2-21 Configuring Apache for PHP on UNIX/Linux Platforms 1. Open the httpd.conf file from the /usr/local/apache2/conf directory 2. Search for the LoadModule directive: LoadModule php5_module libexec/libphp5.so 3. Add the AddType directive to the end of the file: AddType application/x-httpd-php.php 4. Save and close the httpd.conf file 5. Restart Apache with the command: /usr/local/apache2/bin/apachectl restart

PHP Programming with MySQL Slide 2-22 Configuring Apache for PHP on Windows 1. Click the Start menu and point to All Programs 2. Select the Edit the Apache httpd.config Configuration File command 3. Add the following to the end of the file: ScriptAlias /PHP/ “C:/PHP/” AddType application/x-httpd-php.php Action application/x-httpd-php “/PHP/php- cgi.exe” 4. Save and close the httpd.conf file 5. Restart Apache and select the Restart command

PHP Programming with MySQL Slide 2-23 Configuring PHP Figure 2-6 The php.ini configuration file

PHP Programming with MySQL Slide 2-24 Installing and Configuring MySQL on UNIX and Linux 1. Go to and download the latest version of MySQL 2. Create a separate group and user named for running MySQL: groupadd mysql useradd -g mysql mysql 3. Run the gunzip mysql tar.gz command 4. Run the tar xvf mysql tar command 5. Change to the mysql directory

PHP Programming with MySQL Slide 2-25 Installing and Configuring MySQL on UNIX and Linux 6. Run the./configure command 7. Compile the MySQL code with the make command 8. Run the make install command 9. Change to the scripts directory 10. Run the mysql_install_db --user=mysql script 11. Run the ownership commands: chown -R root /usr/local/mysql chown -R mysql /usr/local/mysql/var chgrp -R mysql /usr/local/mysql

PHP Programming with MySQL Slide 2-26 Installing and Configuring MySQL on Windows 1. Go to 2. Open Windows Explorer or My Computer and start the MySQL installation 3. In the Welcome screen, click Next to start the installation 4. Accept the default setup type Typical, click Next 5. Click Back to make changes or click Install to continue

PHP Programming with MySQL Slide 2-27 Installing and Configuring MySQL on Windows 6. Create a new account or skip sign-in, click Next 7. In the Wizard Completed screen, click Finish 8. In the first screen of the MySQL Server Instance Configuration Wizard, click Next 9. In the Configuration Type screen, select Standard Configuration, click Next

PHP Programming with MySQL Slide 2-28 Installing and Configuring MySQL on Windows 10. In the Windows Options screen, accept the default values (do not select the Include Bin Directory in Windows PATH check box), click Next 11. In the Security Options screen, deselect the Modify Security Settings check box, click Next 12. Click Back to change any of the configuration operations or Execute to finish

PHP Programming with MySQL Slide 2-29 Testing the MySQL Server 1. Check to see if MySQL is running  For UNIX/Linux systems: /usr/local/mysql/bin/mysqld_safe --user=mysql &  For Windows, use the Services window 2. Run the mysqladmin version command  For UNIX/Linux systems: /usr/local/mysql/bin/mysqladmin version  For Windows, change to the C:\Program Files\MySQL\MySQL Server 4.1\bin\ directory and run: mysqladmin version

PHP Programming with MySQL Slide 2-30 Creating Basic PHP Scripts Embedded scripting languages (JavaScript or PHP) refer to code that is embedded within a Web page (either an HTML or XHTML document) This code is typed directly into a Web page as a separate section A Web page document containing PHP code must have an extension of.php PHP code is never sent to a client’s Web browser

PHP Programming with MySQL Slide 2-31 Creating Basic PHP Scripts The Web page generated from the PHP code, and HTML or XHTML elements found within the PHP file, is returned to the client A PHP file that does not contain any PHP code should have an.html extension.php is the default extension that most Web servers use to process PHP scripts

PHP Programming with MySQL Slide 2-32 Creating PHP Code Blocks Code declaration blocks are separate sections within a Web page that are interpreted by the scripting engine There are four types of code declaration blocks: Standard PHP script delimiters The element Short PHP script delimiters ASP-style script delimiters

PHP Programming with MySQL Slide 2-33 Standard PHP Script Delimiters A delimiter is a character or sequence of characters used to mark the beginning and end of a code segment The standard method of writing PHP code declaration blocks is to use the script delimiters The individual lines of code that make up a PHP script are called statements

PHP Programming with MySQL Slide 2-34 The Element The element identifies a script section in a Web page document For client-side scripting, the type attribute of the element indicates which scripting language and version is being used When the element is used with PHP, you do not include the type attribute

PHP Programming with MySQL Slide 2-35 Short PHP Script Delimiters The syntax for the short PHP script delimiters is Short delimiters can be disabled in a Web server’s php.ini configuration file PHP scripts will not work if your Web site ISP does not support short PHP script delimiters Short delimiters can be used in XHTML documents, but not in XML documents

PHP Programming with MySQL Slide 2-36 ASP-Style Script Delimiters The syntax for the ASP-style script delimiters is ASP-style script delimiters can be used in XHTML documents, but not in XML documents ASP-style script delimiters can be enabled or disabled in the php.ini configuration file To enable or disable ASP-style script delimiters, assign a value of “On” or “Off ” to the asp_tags directive in the php.ini configuration file

PHP Programming with MySQL Slide 2-37 Understanding Functions A function refers to a procedure that performs a specific task To execute a function, you must invoke, or call, it from somewhere in the script A function call is the function name followed by any data that the function needs The data (in parentheses following the function name) are called arguments or actual parameters Sending data to a called function is called passing arguments

PHP Programming with MySQL Slide 2-38 Displaying Script Results To return to the client the results of any processing that occurs within a PHP code block, you must use an echo() statement or the print() statement The echo() and print() statements create new text on a Web page that is returned as a response to a client

PHP Programming with MySQL Slide 2-39 Displaying Script Results Figure 2-13 PHP Diagnostic Information Web page

PHP Programming with MySQL Slide 2-40 Displaying Script Results The echo() and print() statements are language constructs of the PHP programming language A programming language construct refers to a built-in feature of a programming language The echo() and print() statements are virtually identical except: The print() statement returns a value of 1 if it is successful It returns a value of 0 if it is not successful

PHP Programming with MySQL Slide 2-41 Displaying Script Results Use the echo() and print() statements to return the results of a PHP script within a Web page that is returned to a client A text string, or literal string, is text that is contained within double or single quotation marks To pass multiple arguments to the echo() and print() statements, separate them with commas like arguments passed to a function

PHP Programming with MySQL Slide 2-42 Creating Multiple Code Declaration Blocks For multiple script sections in a document, include a separate code declaration block for each section... Multiple Script Sections First Script Section Output from the first script section. ”; ?> Second Script Section Output from the second script section. ” ;?>

PHP Programming with MySQL Slide 2-43 Creating Multiple Code Declaration Blocks PHP code declaration blocks execute on a Web server before a Web page is sent to a client... Multiple Script Sections First Script Section Output from the first script section. Second Script Section Output from the second script section.

PHP Programming with MySQL Slide 2-44 Creating Multiple Code Declaration Blocks Figure 2-17 Output of a document with two PHP script sections

PHP Programming with MySQL Slide 2-45 Case Sensitivity in PHP Programming language constructs in PHP are mostly case insensitive <?php echo “ Explore Africa, ”; Echo “ South America, ”; ECHO “ and Australia ! ”; ?>

PHP Programming with MySQL Slide 2-46 Adding Comments to a PHP Script Comments are nonprinting lines placed in code such as:  The name of the script  Your name and the date you created the program  Notes to yourself  Instructions to future programmers who might need to modify your work

PHP Programming with MySQL Slide 2-47 Adding Comments to a PHP Script Line comments hide a single line of code Add // or # before the text Block comments hide multiple lines of code Add /* to the first line of code And */ after the last character in the code

PHP Programming with MySQL Slide 2-48 Adding Comments to a PHP Script <?php /* This line is part of the block comment. This line is also part of the block comment. */ echo “ Comments Example ”; // Line comments can follow code statements // This line comment takes up an entire line. # This is another way of creating a line comment. /* This is another way of creating a block comment. */ ?>

PHP Programming with MySQL Slide 2-49 Summary Binary format (or “binaries”) refers to files that can be in the form of executable installation programs Source code is the original programming code in which an application was written Directives define information about how a program should be configured JavaScript and PHP are both referred to as embedded scripting languages

PHP Programming with MySQL Slide 2-50 Summary You write PHP scripts within code declaration blocks, which are separate sections within a Web page that are interpreted by the scripting engine The individual lines of code that make up a PHP script are called statements The term function refers to a procedure (or individual statements grouped into a logical unit) that perform a specific task

PHP Programming with MySQL Slide 2-51 Summary The term programming language construct refers to a built-in feature of a programming language Programming language constructs in PHP are mostly case insensitive, although there are some exceptions Comments are nonprinting lines that you place in code to contain various types of remarks