1 Introduction to PHP 5 Introduction to PHP 5 Presented by Brett Buddin
1 Introduction to PHP 5
Introduction to PHP 5
Presented by Brett Buddin
2 Introduction to PHP 5
What is PHP?
“PHP: Hypertext Preprocessor”• General purpose scripting language
• Most commonly used for server-side scripting
3 Introduction to PHP 5
4 Introduction to PHP 5
Why use PHP?
• Simple syntax
• Easy to learn
• Great performance
• Fantastic online documentation
• Open Source
5 Introduction to PHP 5
History
• Initially released in June 1995 by Rasmus Lerdorf as “Personal Home Page Tools”
• Lerdorf merged PHP with his Form Interpreter to create PHP/FI
• Zeev Suraski and Andi Gutmans rewrote the parser to form the core of PHP 3
6 Introduction to PHP 5
History
• PHP 4 released in May 2000
• PHP 5 released in July 2004
• Today powers millions of applications
7 Introduction to PHP 5
Growth of PHP
Source: Netcraft
8 Introduction to PHP 5
New in PHP 5
• Completely rewritten object model
• Interoperable XML tools
• MySQLi extension
• SQLite embedded
• Exception handling
9 Introduction to PHP 5
Objects in PHP 3 and 4
• Treated as primitive data types
• Assigned and passed by value
• Had to manually force pass by reference
10 Introduction to PHP 5
Objects in PHP 5
• Woven into the core
• Assigned and passed by handle
• This eliminates a lot of ampersands
11 Introduction to PHP 5
Rewritten object model
• Interfaces and Abstract classes
• Class type hints
• Static keyword
• Final keyword
12 Introduction to PHP 5
Rewritten object model
• Cloning
• Constructors and destructors
• Access modifiers
13 Introduction to PHP 5
Cloning
• __clone() method
• Offers a way to create a copy of an object
14 Introduction to PHP 5
Constructors and Destructors
• __construct() and __destruct() methods added
• Old constructor syntax still works
15 Introduction to PHP 5
Access modifiers
• Access modifiers added for properties and methods
• The three P’s:– Public: All scopes have access
– Private: Only local object has access
– Protected: Only local and derived objects have access
16 Introduction to PHP 5
Interoperable XML tools
• Standardized on libxml2• Extensions work together as a whole
• W3C specification compliant
• Very efficient
17 Introduction to PHP 5
MySQLi Extension
• Prepared statements
• Bound input and output parameters
• SSL connections
• Multi-query functions
18 Introduction to PHP 5
SQLite embedded
• No need for flat file databases
• SQLite supports– Transactions
– Subqueries
– Triggers
19 Introduction to PHP 5
Exception handling
• Eliminates the need to check return values for every function
• Separation of business logic and error logic
20 Introduction to PHP 5
PHP’s drawbacks
• Lack of language design
• Inconsistent naming conventions and function behavior
• Almost too popular
21 Introduction to PHP 5
Questions?