Download presentation
Presentation is loading. Please wait.
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: Hey, you are using Netscape! Hey, you are using Netscape! <!--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 Limited Object Oriented Support More speed More speed Numerous DB support (MySQL, ODBC, Oracle, …) Numerous DB support (MySQL, ODBC, Oracle, …) Extensibility 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 Objected Oriented Support Better Error Checking Better Error Checking Java Style try{} catch{} SimpleXML 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 Executing file Code from command line Code from command line Passed code from standard input Passed code from standard input
10
Advantages of CLI Installation Same code can work on Unix or Windows machines ‘#!/usr/bin/php’ ‘#!/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) Delicacy (Security)Apache 2.0 (Thread safety, high-traffic areas) 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) 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 what was submitted in the form parameter called 'user' print $_POST['user']; print "!"; } else { // Otherwise, print the form print <<<_HTML_ Your Name: Your Name: <br/> _HTML_; _HTML_;}?>
17
PHP Your Name: Your Name: <br/> </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"); 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'"); 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 ' Welcome to my site '; print ' Welcome to my site '; print ' '; print ' ';}page_header2('cc00cc');}?>1example-5-04.php
21
PHP Example-A-03.php
22
PHP
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.