Install pear --------------
Pear is a php extension and application library that contains a number of useful classes, and after installing php5.0, pear is not actually installed, and the installation method is as follows:
1. Double-click Go-pear.bat in the PHP directory.
2. According to the prompts to enter a number of settings information, mainly to the LAN gateway Plus, such as http://192.168.0.1:80/, pear to use this address to access the Internet, if no proxy server then direct return, I was directly press ENTER.
3. Then you will be prompted with some packages and PHP bindings, select Y.
4. Then install the basic package and prompt installation success, it is so simple.
5. Open the php.ini file in the Windows directory, and then find the following places:
; UNIX: "/path1:/path2"
; include_path = ".:/ Php/includes "
; Windows: "\path1;\path2"
; include_path = ".; C:\php\includes "
Remove the comment from the last line and change the path back to your pear path, for example:
include_path = ".; C:\php\pear\ "
Save the php.ini, and then restart Apache.
---------------
Pear Command Help ---------------
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, or double-click the generated ev_xxx. REG file. Some of its commands function as follows:
Installation:
Install a pear library from the Internet:
Pear Install PackageName
Download packages but uneasy outfit:
Pear Download PackageName
Pear Download-all
Mounted Package:
Pear Install filename.tgz
List:
The list of all available pear repositories on the Pear Web site today:
Pear remote-list
List Mounted Package:
Pear List
List the package that can be upgraded:
Pear List-upgrades
Update (upgrade):
Update package:
Pear Upgrade PackageName
Pear Upgrade-all
Removal:
To delete an installed package:
Pear Uninstall PackageName
----------------
to install a new package ----------------
For example, you downloaded a new package from http://pear.php.net/package/xxx.tgz.
Copy it to the C:\PHP\PEAR\go-pear-bundle directory and enter it in CMD:
Pear Install xxx.tgz
On the line, the related files were extracted to the C:\PHP\PEAR\ corresponding directory.
---------------
Instance
---------------
Download the Pear::html_common and Pear::html_quickform packages, and then install.
Build a new PHP file, enter the 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 ', ' please login ');
$form->addelement (' text ', ' name ', ' username: ');
$form->addelement (' Password ', ' password ', ' Password: ');
$form the->addelement (' Submit ', ' submit ', ' submit ');
Output to Browser
$form->display ();
?>
</BODY>
</HTML>
Look at the results in the browser, it is not more than you manually write code faster!
=============================================
Example two:
?
Require_once ' mail.php ';
Flush ();
$conf [' mail '] = Array (
' Host ' => ' smtp.163.com ',//SMTP server address, can use IP address or domain name
' Auth ' => true,//true indicates that the SMTP server requires authentication, false code does not need
' username ' => mailuser ',//username
' Password ' => ' MailPassword '/password
);
/***
* Using the $headers array, you can define the contents of the message header, such as using $headers[' reply-to ' to define the reply address
* In this way, you can easily customize the message headers for outgoing messages
***/
$headers [' from '] = ' MailUser@163.com '; Sending address
$headers [' to '] = ' ToEamil@163.com '; Address of the receiving letter
$headers [' Subject '] = ' test mail send by PHP '; Message headers
$mail _object = &mail::factory (' smtp ', $conf [' Mail ']);
$body = ' <<< MSG 2//message body
Hello World!!!
MSG ';
$mail _res = $mail _object->send ($headers [' to '], $headers, $body); Send
if (Pear::iserror ($mail _res)) {//Detect 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.