1 / 22

PHP: Hypertext Preprocessor

PHP: Hypertext Preprocessor. Greg Lowe Rob White Brian Wright Mike Zywiec. Introduction. PHP stands for “PHP: Hypertext Preprocessor” Server-side scripting language Syntactically similar to C Utilized by approximately 33% of web domains on the web. History.

halle
Download Presentation

PHP: Hypertext Preprocessor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP: Hypertext Preprocessor Greg Lowe Rob White Brian Wright Mike Zywiec

  2. Introduction • PHP stands for “PHP: Hypertext Preprocessor” • Server-side scripting language • Syntactically similar to C • Utilized by approximately 33% of web domains on the web

  3. History • 1995 – Rasmus Lerdorf wrote the Personal Home Page/Form Interpreter: PHP/FI • Wanted to create a HTML-centric language as opposed to PERL which was PERL-centric • Code was inside the HTML document and written within <!-- --> Tags • Example: <!--getenv HTTP_USER_AGENT--> <!—ifsubstr $exec_result Mozilla--> Hey, you are using Netscape!<p> <!--endif-->

  4. History • Lerdorf was not satisfied with PHP/FI so he wrote PHP/FI v.2 • Embedded commands within <? > tags • Same syntax used today

  5. History • 1997—Zeev Suraski and Andi Gutmans contacted Lerdorf in an effort to combine their already written engine with PHP/FI v.2 • After agreeing, the three and some others finished the release of PHP v.3 • PHP v.3 gained: • Limited Object Oriented Support • More speed • Numerous DB support (MySQL, ODBC, Oracle, …) • Extensibility • Allowed for programmers to write their own modules for the language

  6. History • Zeev and Andy went to work on what is now called the Zend Engine • The Zend Engine + PHP v3 = PHP4(2000)

  7. History • PHP v. 5 -- 2004 • Better Objected Oriented Support • Better Error Checking • Java Style try{} catch{} • SimpleXML • Easy interaction with XML Documents

  8. Installing PHP • Web Environment • Command Line Interface

  9. Command Line PHP Scripting • Can execute code from command line in three ways: • Executing file • Code from command line • Passed code from standard input

  10. Advantages of CLI Installation • Same code can work on Unix or Windows machines • ‘#!/usr/bin/php’ • Web-independent development

  11. For Server-Side Scripting • Prepackaged solutions • Manually compiling & configuring • Works for Apache 1.3.x/2.0, IIS

  12. Known Issues • IIS • Delicacy (Security) • Apache • 2.0 (Thread safety, high-traffic areas)

  13. PHP Strengths: • Ready to use tools to interface with many databases and web utilities. (MySQL, Oracle, Etc.) • Easily extensible. PHP is modular and it is simple to create utilities to extend the capabilities of the language. • PEAR project (http://pear.php.net)

  14. PHP Strengths: • Server Side processing • No client side software

  15. PHP Weaknesses: • Weakly typed variables. • Poor error detection / warning. • Really only suitable for web applications.

  16. PHP <?php // Print a greeting if the form was submitted if ($_POST['user']) { print "Hello, "; // Print what was submitted in the form parameter called 'user' print $_POST['user']; print "!"; } else { // Otherwise, print the form print <<<_HTML_ <form method="post" action="$_SERVER[PHP_SELF]"> Your Name: <input type="text" name="user"> <br/> <input type="submit" value="Say Hello"> </form> _HTML_; } ?>

  17. PHP <form method="post" action="/~gl1042/PHP/example-1-05.php"> Your Name: <input type="text" name="user"> <br/> <input type="submit" value="Say Hello"> </form> Then when I click on enter the returned information is: Hello, greg! Example-1-05.php

  18. PHP require 'DB.php'; $db = B::connect('mysql://hunter:w)blah@example.com/restaurant'); if (DB::isError($db)) { die("connection error: " . $db->getMessage( )); } // Eggplant with Chili Sauce is spicy $db->query("UPDATE dishes SET is_spicy = 1 WHERE dish_name = 'Eggplant with Chili Sauce"); // Lobster with Chili Sauce is spicy and pricy $db->query("UPDATE dishes SET is_spicy = 1, price=price * 2 WHERE dish_name = 'Lobster with Chili Sauce'");

  19. PHP • <?php • print 'strftime() says: '; • print strftime('%c'); • print "\n"; • print 'date() says:'; • print date('r'); • ?> • 1example-9-01

  20. PHP <?php function page_header2($color) { print '<html><head><title>Welcome to my site</title></head>'; print '<body bgcolor="#' . $color . '">'; } page_header2('cc00cc');} ?> 1example-5-04.php

  21. PHP <?php phpinfo(); ?> Example-A-03.php

  22. PHP

More Related