Install and use PHP PEAR

Source: Internet
Author: User

Install Pear
--------------
Pear is an extension and application of PHP. Program Library, including 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 Code
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> pear: html_quickform </title>
<Meta name = "generator" content = "editplus">
<Meta name = "author" content = "haohappy">
</Head>
<Body>
<?
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 ();
?>
</Body>
</Html>
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 .';
?>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.