Installing Pear
--------------
Pear is a php extension and application library, contains a lot of useful classes, after installing the php5.0, pear is not actually installed, the installation method is as follows:
1. In the PHP directory, double-click Go-pear.bat.
2. Follow the prompts to enter some 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 directly enter, I am directly press ENTER.
3. Then you will be prompted for some packages and PHP bindings, select Y.
4. Then install the basic package and prompt the installation to succeed, as simple as that.
5. Open the php.ini file under the Windows directory and look for 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 then change the back path to your pear path, for example:
include_path = ".; C:\php\pear\ "
Save the php.ini, and then restart Apache.
---------------
Pear Command Help
---------------
In your PHP root directory you can find the Pear.bat file, 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 command functions are as follows:
Installation:
Install a pear library from the Web:
Pear Install PackageName
Download packages but uncomfortable:
Pear Download PackageName
Pear Download-all
Installation of the downloaded package:
Pear Install filename.tgz
List:
The list of all pear repositories available on the Pear Web site now:
Pear remote-list
List Installed packages:
Pear List
List the package that can be upgraded:
Pear List-upgrades
Update (upgrade):
Update package:
Pear Upgrade PackageName
Pear Upgrade-all
To remove:
Remove the installed package:
Pear Uninstall PackageName
----------------
Install a new package
----------------
For example, you downloaded a new package xxx.tgz from http://pear.php.net/package/.
Copy it to the C:\PHP\PEAR\go-pear-bundle directory and enter it in CMD:
Pear Install xxx.tgz
On the line, the relevant files are extracted to the C:\PHP\PEAR\ corresponding directory.
---------------
Instance
---------------
Download the Pear::html_common and Pear::html_quickform packages and install them.
Build a new PHP file, enter the code
<title>Pear::html_quickform</title>
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 ', ' User name: ');
$form->addelement (' Password ', ' password ', ' Password: ');
$form->addelement (' Submit ', ' submission ', ' submissions ');
Output to Browser
$form->display ();
?>
Look at the results in the browser, is not much faster than you manually write code!
=============================================
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, and false code does not require
' username ' + mailuser ',//user name
' 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, it is easy to customize the message header for outgoing mail
***/
$headers [' from '] = ' MailUser@163.com '; Sending address
$headers [' to '] = ' ToEamil@163.com '; Delivery address
$headers [' Subject '] = ' test mail send by PHP '; Message header
$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 above describes the iphone installer PHP Pear installation and use, including the iphone installer aspects of the content, I hope to be interested in PHP tutorial friends helpful.