What's up PHP 5.0
What’s up PHP 5!
PHP 5.0 has 3 major changes. OOP, MySQLi and XML
- Object Oriented Model
Highlight of PHP 5 is OOP. The OOP has included in PHP since PHP3, but it
have many limitations and some bugs. But now PHP5 support:- public, private, protected access modifiers for members and methods
- abstract classed and methods supported
- interfaces classes supported
- final keyword for members and methods supported
- Explicit object cloning supported (use clone keyword or __clone())
- new function for constructor and destructor (__construct() and __destructor())
- constants variable in class supported
- __autoload() will be automatically called when an undeclared class is
to be instantiated - Overload method supported.
- static members and methods supported
- Class type hints supported
- Iterators supported (foreach() function)
- new “__METHOD__” constant for show the current class and method
- new “__toString()” method to show the object as string
- new instanceof operator for is-a relationship check (is_a() have been
deprecated) - Reflection API supported, this API will help you to reverse-engineer
classes, methods, interfaces and functions very easy.
- CGI and CLI
- PHP 5.0 has 3 modes, but it has changes some file name and improve PHP-Win mode.
- Php.exe is CLI (Command Line Interpreter) Mode, on PHP 4.x version is /cli/php.exe
- php-cgi.exe or CGI Mode, on PHP 4.x this file is rename from /php.exe
- Php-win.exe, last one is new mode which call “PHP-Win” mode. This mode
is same CLI mode but it doesn't output anything.
- New Functions
PHP 5.0 has new many functions improve from PHP 4.3.5 such as Arrays, InterBase,
iconv, Streams, etc… functions). More information, please check PHP Manual
- New Directives
PHP 5.0 have new 5 Directives (you can set it on php.ini file)- mail.force_extra_parameters: Force the addition of the specified parameters
to sendmail binary. These parameters will replace value of 5th parameter
in mail() function - register_long_arrays: This allow or disallow to register the long $HTTP_*_VARS.
Default value is ON, but for performance reasons if you not using them I
recommend to turn off. - session.hash_function: Choose hash function for generate session ID.
You can change to 0 for MD5 (128 bits) and 1 for SHA-1(160 bits). Default
value is 0 - session.hash_bits_per_character: This directive define how many bits
to generate Session ID - zend.ze1_compatibility_mode: Directive for Zend Engine 1 Compatible
(PHP 4.2.x)
- mail.force_extra_parameters: Force the addition of the specified parameters
- New Error Report
- E_STRICT this is run-time PHP suggestions to help suggest method of
coding, example: E_STRICT will warn you if you use deprecated functions.
- E_STRICT this is run-time PHP suggestions to help suggest method of
- Another new features
- Exception supported. You can use try/throw/catch structured for exception
handling - Static function variables supported.
- Foreach() now supported references sign (&)
- pass by-value and value to by-reference parameters are supported
- All XML extensions (DOM, SAX, XSL, XSLT) are using libxml2 from xmlsoft.org
- SimpleXML, function suited for read well-known XML file format
- SOAP functions have been rewritten as a C extension
- MySQLi (MySQL Improved) extension. This extension allow you access new
features on MySQL 4.1 or above, such as prepared statements, variable binding,
SSL and compressed connections, transaction control, replication support - SQLite embeddable database engine supported.
- Tidy extension. This extension is utility to clean, repair or traverse
the tree or HTML document. - Memory Management
- Exception supported. You can use try/throw/catch structured for exception
- Read more...
- PHP 5.0 Manual (Download
here) - PHP Info
Center, by Zend.com -
Why
PHP 5 Rocks!, by Adam Trachtenberg - What’s new in PHP 5,
by Zend.com
Comments