Table of Contents
This guide covers great progress of PHP 5 with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.
PHP 5. 0 has made significant improvements compared to previous 4. X PHP versions. So far, PHP 5 has been considered the most significant update in the last 2 years while maintaining the inherent strength of PHP since PHP / FI 2. 0 is speed and efficiency. (Refer to PHP development history on 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, putting Zend Engine 1 into the core of PHP Engine gave PHP 4 the superior power. Although PHP has attracted a large number of users, its main limitation is not providing. Add tools to build websites.
Six years later, the community has seriously considered the inherent persistence of PHP that made it difficult for developers to handle some problems. Among them, developers emphasize the support of object-oriented programming in PHP 4 in a half-hearted way, the MySQL extension library does not support the new MySQL 4. 1 client protocol, supports mixed and mixed XML. Padded.
PHP 5 has improved 3 important issues (completely rewritten) and the results are really impressive. However, this is still not all the best that PHP 5 brings. In this article, I will mention seven outstanding features of PHP 5. These features allow for the development of shorter, more beautiful and more mobile code.
Strong support for object-oriented programming
Although the object support features have been claimed since PHP 4, the developer community has quickly realized their immaturity. With PHP 5, developers now have complete object-oriented programming tools (PHP 5 still allows normal work with structured programming). Can list some characteristics:
1. A completely new object model based on a prototype is Java's model
2. Unified constructor _construct (): facilitates the movement of classes from this class hierarchy to another class hierarchy.
3. Cancellation function _destruct (): facilitates to record information for finding errors, closing data connection and performing other work of releasing resources.
4. Properties and public, protected, and private methods: allow defining the tangibility of class properties. This is very important to support inheritance and encapsulation in object-oriented programming.
5. Interface (Interface): this feature is taken from the Java model to support multiple inheritance.
6. Abstract classes.
7. Class hints (class hints).
8. Static properties and methods.
9. Final properties and methods.
10. A variety of other strong support methods such as auto loading, reflection, exception handling (exceptions), object cloning, instanceof operators.
In addition, the objects are now both assigned and transmitted by reference (reference or handle) instead of by value, so the programmer no longer has to use scattered symbols & throughout the program. . These language features also paved the way for PHP programmers to make the most of the power of pattern designs.
MySQL extension library is completely rewritten
The MySQL database administration system goes hand in hand with PHP as shown with the shadow, although PHP can supporting many other database systems. However, while this combination offers resounding success for both products, the extension of the extension module for PHP to work with MySQL is an obstacle when it does not allow the use of properties. Extremely attractive features of MySQL 4. 1 and higher versions.
The PHP 5 development team has written a completely new, very powerful extension library to support MySQL 4. 1 and 5. X, called MySQLi (MySQL Improved). Features include:
1. Pre-compilation command
2. Parameter export and import are limited
3. SSL connection
4. Multi-query function.
MySQLi also takes advantage of PHP 5's new object-oriented programming support to provide an object-oriented interface with MySQL. Above all, the latest versions of MySQL now allow subselects, transactions and replication.
XML toolkit can interact
PHP 5 has improved XML support with XML libraries expanded as follows:
1. Work together as a whole.
2. Standardized on a single XML library: libxml2.
3. Fully comply with W3 specifications.
4. Effective data processing.
< 5. Provide powerful XML processing tool.
In addition, to continue maintaining the ease of PHP in building web apps, a new XML library has been included to easily read and modify XML documents. The SimpleXML extension module allows interacting with the information contained in an XML document as if the information is an array or an object, can be used to loop through them, edit them in place only by assigning them. New values into variables.
If you already know the format of the document, such as when separating RSS files, configuration data, then use SimpleXML very convenient.
If you like using DOM, you will be very interested in the DOM extension module of PHP 5, this module has been rewritten and greatly improved compared to the version in PHP 4.
Embedded SQLITE database system
Perfect integration with MySQL is a huge advantage for PHP 4. X, but many web apps do not need much to the ability of strong database management system. Therefore, the distribution with the SQLite embedded database system allows developers to have more tools ready to store and query data using the SQL method without installing any separate database system. SQLite correctly handles concurrent access and concurrent access, two outstanding issues when processing self-created flat file files.
SQLite is powerful enough to handle most common data storage and manipulation needs. It supports:
1. Transactions:
2. Subqueries (Subqueries)
3. Referential integrity control (triggers)
4. Many advanced features related to databases such as View support.
SQLite is compatible with most of the standard SQL92 features, but the latest version 3. 0 does not yet support nested transitions, foreign key constraints, and support for full referential integrity control. You can even write functions for users to define themselves in PHP and call them inside SQLite. This is the most prominent feature ever obtained in an extended database related module in PHP.
Better error handling mechanism with Exceptions
PHP 5 provides a completely different error checking model than PHP 4. It is called exception error handling. With an exception, the developer is freed from having to check the return value of all functions. Instead, you can separate the error handling programming logic and place them next to the code blocks.
Exception errors are often seen in object-oriented programming languages like Java and C ++. Currently, only a few PHP extension modules use exception errors, but gradually this will be done synchronously. However, you can use the exception error for any of your PHP code.
Advanced SOAP implementation
SOAP is a key component of the rapidly growing web service sector. SOAP support in PHP 4 is only at the middle level, not only with very few SOAP packages but also in the most important packages written in PHP instead of slow C.
With PHP 5, we finally have an extension module for SOAP written in C. Currently, this module is mostly implemented, although not all the features mentioned in SOAP 1. 2. In the future, this module will be further improved. Currently, compared to. NET or Java, SOAP support in PHP is still ranked below.
INSTALL PHP 5 WITH APACHE 2. 0. X AND MySQL ON WINXP
For example, c: webserverphp5ext) and check if there is a PHP_MySQL. Dll file there. This is the library for PHP 5 to handle data handling calls with MySQL. If you download PHP 5. 0 officially, this file is definitely there. But if you use PHP 5. 0 versions that are being developed and exported as snapshots (HTTP: //snaps. PHP. Net), this file may be removed. If so, find it in the unzipped folder and copy it to the ext subdirectory. - Copy libmysql. Dll file in PHP 5 directory into c: Windowssystem32 folder or bin directory of Apache 2 (for example, c: webserverApache2bin). If you don't do this step, you might get an error 'can't load c: webserverphp5extphp_MySQL. Dll'. - Next, open the Apache conf subdirectory and find the httpd. Conf file. If Apache 2. 0. X is installed by default, its path is c: Program FilesApache GroupApache2confhttpd. Conf. In my case, it is located at c: webserverApache2confhttpd. Conf. Open this file with a plain text editor and navigate to the line #LoadModule ssl_module modules / mod_ssl. So You add the following two lines below this line: LoadModule php5_module 'c: /webserver/php5/php5apache2. Dll' AddType app / x-httpd-PHP. PHP The LoadModule line will allow Apache to load the library module called PHP 5 to perform processing tasks related to PHP files. You need to pay attention to change the path of php5apache2. Dll depending on your case. Now it is time to restart Apache 2. If there are no errors, the system tray appears as shown in Figure 1.
INSTALL MySQL 4. 0 So you have configured PHP 5. 0 and Apache 2. 0 to run them together. You have also configured PHP 5. 0 functions to query MySQL 4. 0. However, you need to install MySQL 4. 0 to have enough PHP 5 programming tools. Installing MySQL 4. 0. 20 is straightforward. Just download a. Zip file. Unzip and run the setup. Exe file. MySQL software will automatically install to the default directory c: MySQL. Then open the folder c: mysqlbin to run the file winmysqladmin. Exe. When you run this program, you will see a window as shown in Figure 2.
This window allows you to provide the name / password of the person with full admin rights to the MySQL Server. Usually this name / password pair is root / localhost or you can leave it blank by default. After the import is complete and press the OK button, this window disappears and in the system tray appears the service icon of MySQL Server as shown in Figure 3.
As such, you already have the MySQL Server running on your computer and ready to handle queries.
Now you can program with PHP 5. Wish you success.
Repeater (Iterator)
Repeaters are a completely new feature in PHP 5. 0. They allow you to use a for-each loop to loop through different data types: directory lists, database result sets, and XML documents. SPL - Standard PHP Library - is a set of repeaters that provides this functionality along with filtering, limiting, caching and changing of repeater results.
Repeaters are a great way to manually remove all the interfering code in your source code.
For example , the DirectoryIterator repeater transforms iterations through directories from writing:
$ dir = opendir ($ path);
While (false! == ($ file = readdir ($ dir))) {
Print '$ filen';
Closedir ($ dir);
Into writing:
Foreach (new DirectoryIterator ($ path) as $ file) {
Print '$ filen';
So there is no reference directory pointer lying in a mess, as well as there is no lack of comparison conditions in the need to check inside the loop.
In addition to the above highlights, PHP 5. 0 also provides:
Improving lines (streams), wrappers and filters.
The line is the concept given in PHP 4. 3, but before PHP 5. 0 it was the least used part. Improvements included in PHP 5. 0 Beta 3 allow the file interface to be read and written to data by using protocol-dependent objects, which are often referred to as wrappers. The line also allows changing the flow of data through them by attaching filters.
Endoscopic code using the Reflection layer.
This set of classes allows you to test classes, methods, parameters, and other things to explore object properties. With them, you can easily create class probes, PHP debuggers and other tools based on collecting object and function details.
The Tidy extension module makes it easy to understand the validity of HTML and XHTML generation. Its smart parser even turns the most arbitrary code-writing pages into pages that strictly adhere to the latest W3C specifications.
The PHP5 command line version now allows processing individual lines, like Perl and awk. You can specify the code to run at the beginning, middle, and end of each line in a file. Y
FAQ
What should I check before following these steps?
Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.
Why might the process not work?
Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.
Can I undo the changes if necessary?
That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.
Reader Comments 0
Sign in with email or Google to join the discussion.