& gt; PHP 5.0 released officially on July 13th is one of the most noticeable events in the developer community. PHP is currently the most commonly used programming language for building dynamic web pages with 16,251,453 domains, and 1,346,521 IP addresses, as of July 18, 2004.
PHP 5.0 has improved significantly compared to previous versions of PHP 4.x. So far, PHP 5 has been considered the most significant update in the past two years, while retaining PHP's inherent strength since PHP / FI 2.0 as speed and efficiency. (Refer to the Wikipedia history of development at Wikipedia at http://en.wikipedia.org/wiki/PHP and other PHP information on the PHP Vietnam community website at http: // www. phpvietnam.net).
Back in 1998, the introduction of Zend Engine 1 into the core of PHP Engine brought the power of PHP 4. Although PHP has attracted a large number of users, but its main limitation is not provided. More tools to build website.
Six years later, the community has seriously looked at the inherent weaknesses of PHP, making it difficult for developers to handle a number of issues. Among them, developers emphasize object-oriented programming support in PHP 4 in half-way, the MySQL extension library does not support the new MySQL 4.1 client protocol, supports patchy XML and mixed padded
PHP 5 has improved the 3 key issues (completely rewritten) and the results are really impressive. However, this is not all that good PHP 5 brought. In this article, I will cover seven key features of PHP 5. These features allow for shorter, nicer, and more dynamic code development.
Strongly supports object-oriented programming
Although the object support features have been claimed from PHP 4, however, the developer community has quickly realized their immaturity. With PHP 5, developers now have complete object-oriented programming (PHP 5 still works fine with structured programming). Some features may be listed:
A completely new object model based on the prototype is the Java model
& lt; Constructor _construct (): Creates a condition for moving classes from hierarchical to hierarchical.
_destruct (): Enables the recording of information for fault finding, data connection closure, and other resource release tasks.
Public, protected, and private methods and attributes: This allows defining the visibility of class attributes. This is important to support inheritance and packaging in object-oriented programming.
Interface: This feature is derived from the Java model to support multiple inheritance.
Abstract classes
Class hints.
Properties and static methods.
Final attributes and methods.
A variety of powerful support methods such as auto loading, reflection, exception handling, object cloning, instanceof ...
In addition, objects are now both assigning and transmitting by reference or handle instead of by value, so developers no longer have to scatter the & amp; throughout the program. These language features have also opened the way for PHP programmers to optimize the power of the pattern.
The MySQL extension library is completely rewritten
MySQL parallel database management system with PHP as the shadow, although PHP is capable of supporting many other database systems. However, while this combination brings tremendous success for both products, the backwardness of the expansion module for PHP to work with MySQL is an obstacle when it does not allow for the use of features. Extremely attractive feature of MySQL 4.1 and higher.
The PHP 5 development team has written a completely new, very powerful extensible library to support MySQL 4.1 and 5.x, called MySQLi (MySQL Improved). Features include:
Commands precompiled
The export and import parameters are limited
SSL connection
Multi-query function.
MySQLi also takes advantage of the new object-oriented programming support of PHP 5 to provide an object-oriented interface to MySQL. On top of that, the latest versions of MySQL now allow for subselects, transactions, and replication.
XML toolkit can interact
PHP 5 has improved XML support with extended XML libraries as follows:
Work together as a whole.
Standardized on a single XML library: libxml2.
Fully complies with W3 specifications.
Data processing efficiency.
& lt; Provides powerful XML processing engine.
In addition, in order to maintain the simplicity of PHP in building Web applications, a new XML library has been introduced that allows for easy reading and modification of XML documents. The SimpleXML extension module allows interaction with information contained in an XML document as if the information was an array or object, which could be used to loop through them, editing them locally by assigning them only new values into variables.
If you know the format of the document, for example, when decomposing RSS files, configuration data using SimpleXML is very convenient.
If you prefer to use the DOM, you will be very interested in PHP 5's DOM extension module, which has been rewritten and improved a lot in PHP 4.
Embedded SQLITE database
The perfect connection with MySQL is a great advantage for PHP 4.x, but sometimes the web application does not need much to the ability of powerful database management. Therefore, the embedded distribution SQLite embedded database allows developers to have more tools ready to store and query data by SQL method without installing any separate database. SQLite correctly handles locking and concurrent access, two of the most prominent issues in dealing with flat file files.
SQLite is powerful enough to handle most of the storage and data manipulation needs. It supports:
Transactions:
Subqueries
Referential integrity control (triggers)
Many advanced database related features such as support for View ...
SQLite is compatible with most of the standard features of SQL92, but the latest 3.0 does not support nested, foreign-key constraints, as well as full reference control support. You can even write functions for user-defined functions in PHP and call them inside SQLite. This is the most prominent feature ever to be found in a database-related extension module in PHP.
Fault processing mechanism is brighter with Exceptions
PHP 5 provides a completely different error-checking model than PHP 4. It has an exception handling name. With exception, developers are freed from having to check the return value of all functions. Instead, you can separate the error-processing logic and place them next to the code blocks.
Exception errors are often found in object-oriented programming languages such as Java and C ++. Currently, only a few PHP extensions use exceptions, but gradually this will be done synchronously. However, you can use exceptions for any of your PHP code.
Advanced SOAP implementation
SOAP is a key component of the rapidly evolving web services sector. SOAP support in PHP 4 is just average, not only because there are very few SOAP packages, but also because the most important packages written in PHP are C instead of C.
With PHP 5, we finally have an extension module for SOAP written in C. Currently, this module is largely executable, though not all of the features outlined in SOAP 1.2. In the future, this module will be improved. Currently, compared to .NET or Java, SOAP support in PHP is still in the background.
INSTALL PHP 5 WITH APACHE 2.0.X AND MYSQL ON WINXP |
||||||||
The software needed: |
For example, c: webserverphp5ext) and check if the php_mysql.dll file exists there. This is the library for PHP 5 to handle calls to the data processing functions with MySQL. If you download the official PHP 5.0, this file is definitely there. But if you are using PHP 5.0 development and export as a snapshot (http://snaps.php.net), this file may be dropped. If so, look for it in the extract folder and copy it to the ext directory. MYSQL SETTLEMENT 4.0 This window allows you to provide the name / password of the MySQL Server Administrator. Usually, this username / password pair is root / localhost, or you can leave the password blank by default. When done, click the OK button, the window disappears and the MySQL Service icon appears in the system tray, as shown in Figure 3. As such, you already have MySQL Server running on your computer and are ready to handle queries. CHECK INSTALLATION RESULTS Now you can program with PHP 5. Wish you success. |
Pham Cong Dinh
pcdinh@yahoo.com Refer:
- Changes in PHP 5: http://www.php.net/ChangeLog-5.php
- Book of PHP5 and MySQL Bible by Wiley Publishers 2004.
- Book of PHP and MySQL for Dummies 2nd Edition 2004 by publisher Wiley
Repeater (Iterator)
Repeaters are a completely new feature in PHP 5.0. They allow you to use the for-each loop to loop through different types of data: directory listings, database result sets, and even XML documents. SPL - The standard PHP library - a set of repeaters that provides this functionality along with filtering, limiting, caching, and repeater changes.
Repeaters are a great way to manually remove all interfering code in your source code.
For example , the DirectoryIterator repeats the iteration of the directory from the spelling:
$ dir = opendir ($ path);
while (false! == ($ file = readdir ($ dir))) {
print $ filen;
closedir ($ dir);
to write:
foreach (new DirectoryIterator ($ path) as $ file) {
print $ filen;
So there is no reference pointer to any directory that is cluttered into it, nor is there any lack of clear compiler conditions that need to be checked within the loop.
In addition to the above highlights, PHP 5.0 also provides:
• Streams, wrappers and filters.
The line is the concept given in PHP 4.3, but before PHP 5.0 it was little used. The improvements introduced in PHP 5 Beta 3 allow for a file interface to read and write data using protocol-dependent objects, which are often referred to as shell names. Streams also allow for changing the flow of data through them by attaching them to the filters.
• Enumeration of code using Reflection classes.
This set of classes allows you to test classes, methods, parameters, and other things to probe the properties of an object. With them, you can easily create class probes, PHP debuggers and other tools based on gathering details about objects and functions.
Generate standard HTML code thanks to Tidy.
The Tidy extension module makes it easy to grasp the creation of valid HTML and XHTML code. Its smart separator even turns the most arbitrary code pages into pages that comply closely with the latest W3C specifications.
Better command line handling
The PHP5 command line now handles individual streams, like Perl and awk. You can specify the code to run at the beginning, in the middle, and at the end of each line in a file