PHPPear installation and use
Install pear --------------
Pear is a PHP extension and application library. it contains many useful classes. after php5.0 is installed, pear is not actually installed. the installation method is as follows:
1. double-click the go-pear.bat in the php directory.
2. enter some settings as Prompted. add the LAN gateway, such as http: // 192.168.0.1: 80/and pear, to access the Internet, if there is no proxy server, press enter.
3. you will be prompted to bind some packages to PHP and select Y.
4. install the basic package and prompt that the installation is successful.
5. open the php. ini file in the windows directory and find the following:
; UNIX: "/path1:/path2"
; Include_path = ".:/php/shortdes"
; Windows: "\ path1; \ path2"
; Include_path = ".; c: \ php \ shortdes"
Remove the comment from the last line and change the following path to your PEAR path, for example:
Export de_path = ".; c: \ php \ pear \"
Save PHP. INI and restart APACHE.
---------------
Pear command help ---------------
You can find the PEAR. bat file in your PHP root directory. this is the command for managing pear. used in CMD, you need to set the environment variable PATH, or double-click the generated EV_XXX.REG file. Some of its command functions are as follows:
Security Protection:
A pear program running on the web server:
Pear install packagename
The following packages are not supported:
Pear download packagename
Pear download-all
The package of the specified region is as follows:
Pear install filename. tgz
List:
Currently, all pear program regions can be obtained on the pear website:
Pear remote-list
List installed packages:
Pear list
List packages that can be upgraded:
Pear list-upgrades
Update (upgrade ):
Update package:
Pear upgrade packagename
Pear upgrade-all
Remove:
Remove the installed package:
Pear uninstall packagename
----------------
Install a new package ----------------
For example, you downloaded the new package xxx.tgzfrom http://pear.php.net/package.
Copy it to the C: \ PHP \ PEAR \ go-pear-bundle directory and enter:
Pear install xxx. tgz
Then, extract the related files to the directory C: \ PHP \ PEAR.
---------------
Instance
---------------
Download the PEAR: HTML_Common and PEAR: HTML_QuickForm packages and install them.
Create a new php file and enter the code
PEAR: HTML_QuickForm
Require_once ("HTML \ QuickForm. php ");
// Create a form object
$ Form = new HTML_QuickForm ('frmtest', 'post ');
$ Form-> addElement ('header', 'header', 'login ');
$ Form-> addElement ('text', 'name', 'username :');
$ Form-> addElement ('password', 'password', 'password :');
$ Form-> addElement ('submit ', 'submit', 'submit ');
// Output to the browser
$ Form-> display ();
?>
Check the results in the browser. is it much faster than manually writing code!
========================================================== =====
Example 2:
Require_once 'mail. php ';
Flush ();
$ Conf ['mail'] = array (
'Host' => 'smtp .163.com ', // smtp server address, which can be an IP address or domain name
'Auth' => true, // true indicates that the smtp server needs to be verified. false indicates that the code does not need to be verified.
'Username' => mailuser', // User name
'Password' => 'mailpassword' // password
);
/***
* You can use the $ headers array To define the content of the mail header. for example, you can use $ headers ['reply-to'] To define the Reply address.
* In this way, you can easily customize the mail header to be sent.
***/
$ Headers ['from'] = 'mailuser @ 163.com '; // mail address
$ Headers ['to'] = 'toeamil @ 163.com '; // recipient address
$ Headers ['subobject'] = 'Test mail send by php'; // mail title
$ Mail_object = & Mail: factory ('smtp ', $ conf ['mail']);
$ Body = '<MSG 2 // mail body
Hello world !!!
MSG ';
$ Mail_res = $ mail_object-> send ($ headers ['to'], $ headers, $ body); // send
If (PEAR: isError ($ mail_res) {// Check the error
Die ($ mail_res-> getMessage ());
}
Echo 'send finished .';
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.