Similar presentations

2
8/17/2015CS346 PHP2 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

4
8/17/2015CS346 PHP4 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.

6
8/17/2015CS346 PHP6 Getting Started with PHP To develop and publish PHP scripts you need: A Web server with PHP built into it A Web server with PHP built into it A client machine with a basic text editor and Internet connection A client machine with a basic text editor and Internet connection FTP or Telnet software FTP or Telnet software

7
8/17/2015CS346 PHP7 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

9
8/17/2015CS346 PHP9 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 2. Use FTP to copy the file to the server 3. Access your file via URL using a browser IE, Netscape, Opera, etc.IE, Netscape, Opera, etc.

10
8/17/2015CS346 PHP10 Check PHP installation  Create a simple PHP script, called checkphp.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 server For WAMP: wamp/www For WAMP: wamp/www  Access the file with a browser  http://localhost/checkphp.php

12
8/17/2015CS346 PHP12 Creating a PHP Script File  Create a simple PHP script, called welcome.php The PHP script starts with a The PHP script 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 http://127.0.0.1/welcome.php  demo

13
8/17/2015CS346 PHP13 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.

14
8/17/2015CS346 PHP14 Copying Files To A Web Server with FTP 1. Connect to the Internet and start FTP. 2. Connect to your Web server with FTP. 3. Copy files to the Web to the Webserver.

18
8/17/2015CS346 PHP18 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.

19
8/17/2015CS346 PHP19 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 with extension php

22
8/17/2015CS346 PHP22 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:

23
8/17/2015CS346 PHP23 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.

24
8/17/2015CS346 PHP24 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 ?>

26
8/17/2015CS346 PHP26 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. */

27
8/17/2015CS346 PHP27 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

28
8/17/2015CS346 PHP28 Summary  Resources needed: 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

29
8/17/2015CS346 PHP29 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 */