">
Home > Backend Development > PHP Tutorial > What is apec conference php what is PEAR?

What is apec conference php what is PEAR?

WBOY
Release: 2016-07-29 08:39:31
Original
1014 people have browsed it

PHP enthusiasts will love PEAR. Our purpose is to introduce PEAR to PHP program developers. I personally think that the program development method that references libraries has gradually become a trend. In addition to PHP and JSP, other programs such as perl and C++ are also There is a dedicated library for its developers to reference.
By introducing PEAR, PHP program developers can not only greatly reduce the work and time of writing code, but also get many powerful dynamic web page functions in a very simple way. I will list many examples for everyone to see. After hearing it, I will definitely applaud and become deeply fascinated by PEAR. In addition, the program code is easy to maintain and high security are two other attractive advantages of PEAR. The PAER program library is like a module and can be easily replaced and updated without affecting other program codes at all.
We start from the most basic concepts, including the meaning of the proper noun PEAR? Where to get the PEAR package? How to use the PEAR package, etc.?
Starting from Chapter 2, we first introduce the origin of PEAR, The history and characteristics give everyone a basic understanding of PEAR.
In Chapter 3, we will introduce the installation and management methods of the PEAR library suite. This chapter is very important. Before using PEAR, you must first learn these basic skills. Although it is a bit complicated, it will be useful once you learn it. Your PHP program development efficiency is doubled, and its functions are improved accordingly.
Chapter 4 uses a simple example to introduce how to use the PEAR library to develop PHP programs. It allows us to understand the general use of PEAR and establish a basic operation process for the use of the library.
In Chapter 5, we will introduce several examples of simple-to-use and powerful program library suites, allowing you to quickly create some very cool functions that you could not imagine before on dynamic web pages, and your program development skills will be instantly improved. improve. For example:
◆ Let the web page provide weather forecast function and increase the added value of the web page.
◆ Use a very simple method to create a cache of web pages on the server to speed up the opening of web pages.
◆ Search the dynamic web page for services provided by a certain host with PORT numbers.
◆ Query a domain name (DNS) on a dynamic web page and find the corresponding IP.
◆ Dynamically generate HTML tables.
◆ Quickly establish a "customer reply" system, allowing web viewers to send letters to webmasters from the web page.
◆ Allow web pages to record the behavior of web browsers, that is, log.
Chapter 6 to Chapter 13, we will introduce in detail how to use some important, commonly used, but more complex library packages. These chapters are all based on the introduction of packages, that is to say, a This chapter only introduces one package, trying to introduce the more important functions of these important packages to everyone in detail.
These packages include: database connection package, form production package, identity authentication package, file upload package, paging package, etc.
Finally, Appendix A will give a detailed introduction to the official website of PEAR. When you enter the world of PEAR, you will definitely come to this website frequently to find information. Knowing how to use the official website is very important for PEAR PHP developers. Appendix B will give a brief introduction to PHP's object-oriented programming.
Those who like and are suitable to use PEAR are classified as follows:
◆ PHP lovers, you must use PEAR, because it is absolutely awesome.
◆ Professional programmer in PHP. What you need is code security, reproducibility, and good work efficiency. PEAR is an absolute must.
◆ PHP programmers who want to develop more interesting and more powerful applications, but don’t want to be tied up in some troubles of writing PHP programs, PEAR can definitely meet your requirements.
◆ If you write PHP programs yourself, but don’t like to start from scratch every time and type the code word by word, PEAR can improve your work efficiency.
◆ If you want to learn PHP with strong functionality and high security, you can try using PEAR after you have learned the basic syntax of PHP.
◆ You need tailor-made PHP applications, in other words, you don't like packaged applications like XOOPS, try PEAR.
◆ You need a PHP application that is easy to maintain, and you don’t want to modify the code frequently in the future, or redesign the entire program due to PHP revisions.
◆ You want your PHP program to be object-oriented to facilitate program swapping and modularization.
◆ If you want to take your PHP skills to the next level and learn more PHP-related knowledge, using PEAR or watching the source code of PEAR is a good way to learn.
PEAR is specially written for people with the above needs.
Using PEAR is like building a house. It allows you to use prefabricated components to build a large house that you design and construct by yourself, but you don't need to mix the cement yourself, prepare the sand, stones, or bake the tiles yourself. Make your own aluminum doors and windows, do your own carpentry decoration, etc...
PEAR is like prefabricated parts that have been customized and prepared according to your needs. You just need to use creativity to combine them.
When we use PEAR to write PHP programs, we must have a prerequisite, that is, we must have a certain understanding of PHP-related knowledge.
If you don’t know what PHP is, what Apache and Mysql are, or even though you know it, you don’t know the basic syntax of PHP, then this article is not suitable for you at the moment. It is recommended that you buy some introductory books on PHP, Apach, and Mysql and study them in detail before reading this article.
You don’t have to be a PHP expert, but you must have the ability to understand basic PHP program code. In any case, first of all, a love for PHP is the most basic prerequisite for reading this book.
Chapter 2
PHP has many specifications and syntax. We will not introduce them. Please read books about PHP when you have time. We will focus on the development of PHP after version 4.0. It has added the function of Object-Oriented Programming Language. Although it cannot be completely object-oriented like Java, it is a big improvement compared to the previous version PHP3.0, and it also provides PHP program developers with Provides more powerful and convenient development capabilities.
PHP version 5.0 and above has been transformed into a completely object-oriented version, providing more complete object-oriented functions. The PEAR library we introduced fully supports PHP 4.3.0 and above. Please rest assured on this point.
For the sake of most people, and also taking into account the downward compatibility of PHP, the content and examples in this book can be executed in the environment of PHP version 4.3.0 or above, because PEAR fully supports PHP version 4.3.0 or above. In environments smaller than PHP 4.3.0, most of PEAR is supported, but only a small part is not supported.
What is object-oriented in PHP? Object-oriented syntax is rarely seen in traditional PHP programs, but if you understand the programming language JAVA, you should be able to know what is object-oriented. I will explain it in Appendix B Object-oriented for a simple explanation.
In addition, I want to emphasize that in addition to basic syntax, PHP has more than a thousand built-in functions, spanning hundreds of categories, including text functions, numeric functions, database classes, and graphics. Classes, etc., the functions are quite powerful and astonishing. But for program developers, how to make good use of these functions and write effective and easy-to-manage code in conjunction with PHP syntax will be a big challenge.
Today, PEAR, a crystallization of wisdom produced by many of the world's top PHP masters, allows us to write code easily and efficiently, and overcome many writing difficulties. Taking the martial arts world as an example, writing PHP with PEAR is like hundreds of martial arts masters pouring their skills into program developers. Program developers do not need to start from the most basic practice of Zha Ma Bu. By borrowing their skills, they can easily double their skills and double their efficiency.
After talking for a long time, what is PEAR? The author will introduce it in the next unit.
The word PEAR simply means "pear" literally.
A pear. The URL of the official website is http://pear.php.net
An example can be seen in the logo of the PEAR official website.
PEAR started on November 2l, 1999. There is a Mr. Stig S. Bakken. This man initiated a project and called on many PHP experts to join in. He first established some basic rules of programming for this project and hoped that PHP developers would join this project. All PHP code written during the project needs to comply with these rules.
The name of this project is PEAR, which is actually the abbreviation of PHP Extension and Application Repository, which means "PHP Extension and Application Repository". To put it simply, PEAR is actually a PHP program library.
The basis of the program code created by Mr. Bakken is as follows. I will only briefly explain it without going into the details:
◆ If the developer wants to provide a PHP program library, the structure of the program must be objectified.
◆ The indentation of the program must follow a certain format
◆ The naming of categories in the program must also follow a certain format
◆ The comments of the program code must follow a certain format
◆ The file naming must follow a certain format
◆ The program library is written Finally, it needs to be packaged into kits, and the packaging and installation methods of the kits also have a certain format.
This project welcomes all PHP developers to jointly develop PHP libraries, as long as they are willing to abide by the above basic rules of coding. Mr. Bakken also organized a team to serve as the control body of this project, responsible for reviewing the libraries provided by all developers participating in the project. If they pass the review, the libraries will be classified and placed on the official website for other developers to download and use. , In addition, this group is also responsible for maintaining and updating the official website.
Some people may be curious, why would someone be willing to write a program library for free for others to use? This is the spirit of the open source world - mutual assistance and sharing. Just imagine, if each developer develops a program library for other people to use in the part he specializes in, and also enjoys the program libraries released by other developers, is it possible to achieve the purpose of mutual assistance and allow every developer to share everything? The results of developers. You don't have to write all the code yourself.
What’s even better is that these libraries are free and open to people all over the world. Not only developers who participate in the development of the libraries can enjoy them (this approach is the same as Java or Perl providing function libraries).
Therefore, all PHP developers around the world can save a lot of time in writing codes, and because developers who use the library can report library deficiencies to the original developers, the original developers will constantly correct these programs. library, so the code is relatively safe. In addition, library developers will also add new functions to the library as the times evolve, so that library users can keep pace with the times.
For details, please refer to the description of the purpose of developing PEAR mentioned in PEAR's official website: http://pear.php.net/manual/en/about-pear.php. I suggest you read it slowly when you have time. If you continue to read this article, you will slowly understand the magic of PEAR.
I have an appendix at the end of the article: an introduction to the PEAR official website, you can refer to it first.
If you don’t quite understand what I mean by “program library”, it doesn’t matter. I will explain it through practical examples in the next section.
2-3 Introduction to all packages
▓ Library VS Suite
Before introducing all packages, we must clarify two terms to avoid confusion among readers. One is "library" and the other is "package".
Suppose I am a PHP developer and develop a "library" that can handle all database access, and want to add this library to PEAR to share it with the world. After I finished writing the database management library, I had to compress the library into a "file" file according to PEAR's regulations and put it on the PEAR official website for everyone to download. This package can be installed or managed using PEAR's package management instructions, which is very convenient for PEAR users. Regarding the package management instructions, I will give a complete explanation in the next chapter. After the above explanation, I believe readers should understand What is a "program library" and what is a "package"? In fact, to put it simply, the program library is packaged into a suite.
▓ Kits and Categories
PEAR has released more than 300 kits so far, divided into 35 categories, and the number is constantly increasing. You can imagine what a uniting force the world's top PHP developers can bring together. The picture below shows the classification of kits on the official website:
PEAR has released too many kits. For the convenience of management, the kits are classified according to their functions. Kits of the same type are related in effect, but provide The functions are not the same. Next, I will give a brief introduction to all categories in a table to let everyone know more about what functions the PEAR suite can provide.
So many categories, each category will develop different kits according to different functions. Take the first authentication category as an example. If you go to the official website, you will find that there are currently 8 packages in this category. These 8 packages are all related to identity authentication. If you want your webpage to have identity authentication Functions, for example, allow web visitors to register, enter account and password, identify identities, grant permissions, etc. You will need these kits.
I would like to add one more thing: some packages have matured and developers will call them stable versions. However, if the library is still under development but can be used, and developers release it, it will usually be called stable version. It is an alpha or beta version. The official website will also record the names of the developers and maintainers of the package. Sometimes a package is developed by many people.
Information on these kits can be found on the PEAR official website. I will introduce how to use the PEAR official website in the appendix "Introduction to the PEAR official website".
2-4 Simple examples of using the PEAR library
In this section, I use a simple example to illustrate the use of the library.
Suppose you want to create a web page and want to know the time it takes to execute the web page, you can borrow a library called Benchmark released by PEAR. This library was developed to calculate the execution time of web pages.
First, install the Benchmark library package (please refer to the next chapter for the installation method). Then we can start writing web pages. For example: we created a web page named show.php.
For the convenience of explanation, I add a line number in front of each line of the program. In fact, you don't need to add a line number when writing the program.
The code in lines 1 and 2 first references the Timer.php web page in the Benchmark package. This web page contains a library for calculating the execution time of the program page. include_once can put an external web page into this page. I call this action "reference". This example is equivalent to executing two web pages, Timer.php and show.php.
Line 3, use the new keyword to create a Benchmark_Timer object and put the object into a variable named $timer. Then use the start() method of the $timer object to start the clock, and then add my own code, in this case a simple line of code.
The next step is to end the clock, calculate the time it takes to execute the web page and display it. Line 8 first uses the stop() method of the $timer object to stop the clock, and uses the timeElapsed() method of the $timer object on line 9 to calculate the time difference from starting to stopping the clock, and puts the calculation result into the $totaltime variable.
Finally, use the echo function to display the time difference on the web page.
From the results, we can clearly see that it took a total of 0.00013613700866699 seconds for the show.php web page to be executed from the beginning to the end. You can observe this number in the future to judge system performance, or as a reference for code improvement. How about, isn’t the calculation of execution time convenient, fast and magical!
If you need to have the function of calculating the execution time of a web page on other web pages, just use the above method to apply it to other PHP web pages.
In fact, the usage of other kits is similar to the usage of this kit. The difference is only in the categories, methods and parameters used by each package.
Although the package is easy to use, I believe readers still have many doubts? For example:
1. Where does the Benchmark library package come from? What preparatory work is required to use it?
2. How do I know how to use the Benchmark package? Method?
The first question involves how to install the PEAR package, as well as the management, upgrade, and deletion of the package after installation. I will introduce it in Chapter 3. For the second question, the author will give a detailed explanation in Chapter 4 on how to use the kit and how to obtain information about the kit.
2-5 Why use PEAR
Why use PEAR? Based on my own experience, I have summarized the following points:
1. Save time and effort: Many codes are written in the program library, and developers only need to quote the The PHP file of the program library can have the functions provided by the program library, saving the time and energy of writing it by yourself.
2. Security: Since these library packages make the source code public, if users find bugs, they can immediately report them to the developers of the packages, and the developers will usually correct them immediately to minimize library errors.
3. Easy to maintain: The self-written code is separated from the code of the PEAR library. If the PEAR package releases a new version because new features are developed or errors are corrected, you only need to update the package and it will not be touched at all. Self-written code.
4. Powerful functions: PEAR suite provides many functions, in addition to common functions such as: database link, configuration file processing, identity authentication, and form processing. In addition, more advanced functions, such as online post office, network management, dynamic generation of graphics, RSS, Wiki, or BBCode analysis like phpBB, etc. can be easily implemented.
5. Separate program development and layout design of web pages: PEAR provides many sample program libraries to separate program development and layout design, making it easier for program developers and web designers to work together.
6. It is an excellent learning example for those learning PHP: the annotations of the program library are very detailed, and the writing of the program code has certain rules and formats, and is completely materialized, making it easy for developers to understand and learn. Some packages also come with teaching files and sample files. The most important thing is: you can get them without spending half a dime. We should thank the authors of the packages for their selfless contributions to us.
2-6 Why establish the PEAR community
What is the reason that prompted PHP developers around the world to unite and jointly develop the program treasure house PEAR? I think there are the following reasons:
1. Suffer strong competition from other competitors: This point has been explained in Chapter 1.
2. Materialization of PHP: After adding material-oriented functions from PHP4, PHP5 is further materialized. In addition to competing with ASP.NET and JSP, it also facilitates the modularization of programs and enables the development of program libraries. Only with materialized functions can the program libraries be separated from the program codes written by developers themselves.
3. Common needs of developers: If every time you develop a PHP program, you have to do it from scratch. Although you can exercise your programming skills, it is inefficient and not very economical. If some commonly used functions can be handled in the form of a program library, it will solve many developers' difficulties. Based on this need that all developers have in common, let these PHP developers work together to develop the program library to help themselves and others.
2-7 Competitors, Advantages and Disadvantages of PHP
PHP was developed in 1994. After four major rewrites, it has become the widely used and mature product we see today. As of April 2005, PHP has been used on more than 19 million websites around the world, and this number continues to grow rapidly.
Compared with their competitors, PHP has the following advantages:
High performance: It’s not just me selling melons, haha. .., I have browsed many Asp.NET and Jsp web pages, but the performance is really not comparable to PHP. (Users of Asp.NET and Jsp probably won’t read this article).
● Can be connected to many different database systems: other competitors can also work, but not as fast as PHP.
● Easy to learn and use: The writing method of PHP code is very intuitive and easy to learn.
● Support object orientation: Jsp is strong in this aspect, but PHP5 has caught up.
● Low cost: no money at all.
● There are a lot of built-in libraries: I remember that I used Asp before, and there were really few built-in libraries.
● Open source code: The security will be higher than if it is not open source.
● PEAR library: This is the latest powerful weapon, used to compete with powerful enemies.
● Portability: PHP can be used on all types of Unix operating systems, such as Linux, FreeBSD, commercial Unix or Windows operating systems.
Asp.NET and Jsp certainly have their unique advantages? For example, Jsp carries the powerful functions of JAVA, and it can present some effects that PHP cannot currently achieve. Therefore, Jsp has also attracted many users, but the author is really not satisfied with the current performance of Jsp. On the contrary, I am extremely satisfied with the speed of PHP.
Which program to use is up to you to make a clear decision. However, if you choose to read the article, I believe that we should all be in the same camp, PHP enthusiasts.
All in all, many PHP experts have jointly built a strong support network. If you are a PHP program developer, but you don’t appreciate the kindness of these experts, wouldn’t it be a pity?

The above introduces what is apec conference php and what is PEAR? , including what is the apec conference content, I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template