When you use PHP to develop a website, when you have a lot of forms to deal with, when you need to use standard SQL statements, when you want to automate the build document. In short, when you want to develop PHP-based Web sites and applications quickly and efficiently, the Pear library will provide you with unexpected help, and using pear to develop PHP programs is a wise choice.
What libraries are available for pear? The Pear Library covers almost any aspect of what you can do with PHP:
1. HTML Form Form page pagination template, very convenient;
2. GTK and GTK2, PHP can also write applications;
3. Images used to process images
4. DB is used to manipulate the database
5. MDB and MDB2, this is also used to manipulate the database, and is the new version
6. XML, XML, this is so strong that you can't imagine it.
7. Mail Email library that can help you save a lot of things
8. HTTP this is used to handle network protocols.
9. Math, mathematical calculations, if your program needs a lot of accurate math, you can use it
Let me introduce you so much first. There are thousands of Pear's libraries, which you can find in http://pear.php.net.
OK, here's the installation of pear (many people find it difficult to install pear, which is actually a very easy thing to do).
Let's say you installed the PHP4.30 version,
1. Double-click the go-pear.bat in your PHP directory
2. Just a direct return.
3. Then you'll be prompted for some packages and PHP bindings, select Y, enter
4. Well, your pear is installed, it's too easy, isn't it?
5. Open your PHP profile C:\windows\php.ini. Then find; include_path= ".;D: \ Php\includes modified to Include_path= ".;D: \ Php\includes;d:\php\pear "
6. Save PHP.ini, restart Apache,ok, all normal. Your pear has been installed successfully!
Simple operation under the Pear command line
You can find the Pear.bat file in your PHP root directory, which is the command to manage pear, used in cmd, to set the environment variable path.
The following command operates under the DOS window (please change the packegename to the package you want to use)
1. Pearinstallpackagename, install a new pear package, such as installing the DB operation is D:/PHP/PEARPEARINSTALLDB
1. Download but not install: Peardownloadpackagename
Peardownload-all
2. List of all available pear libraries on the Pear Web site:
Pearremote-list
3. List Mounted Package:
Pearlist
4. List the package that can be upgraded:
Pearlist-upgrades
5. Update (upgrade):
Pearupgradepackagename
Pearupgrade-all
To delete an installed package:
Pearuninstallpackagename
Here's a simple example of a form that we create.
First install the Html_quickform package
The method is as follows:
PearinstallHTML_QuickForm
Bauan Well, you can write code.
require_once("HTMLQuickForm.php");//首先调用这个包
$form=newHTML_QuickForm('frmTest','post');//创建一个对象
$form->addElement('header',header','登录页面');//设定页面信息
$form->addElement('text','user_name','用户名:');//设定用户登录输入框
$form->addElement('password','user_password','密码:');//设定用户密码
$form->addElement('submit','submit','提交');//设置提交按钮
$form->display();//把设定的信息输出到浏览器
?>