当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP 5.0 Pear安装方法

PHP 5.0 Pear安装方法

2019年06月10日  | 移动技术网IT编程  | 我要评论
pear是php的扩展和应用程序库,包含了很多有用的类,安装好php5.0后,pear实际上并没有被安装,安装的方法如下:  
1.在php目录中双击go-pear.bat。 
2.按照提示输入一些设置信息,主要是要把局域网的网关加上,如http://192.168.0.1:80/ ,pear要用这个地址访问internet,若无代理服务器则直接回车  
3.然后会提示一些包和php绑定,选择y 。 
4.然后安装基本包和提示安装成功,就这么简单。 
5.打开windows目录下的php.ini文件,然后查找到如下的地方: 
; unix: "/path1:/path2" 
;include_path = ".:/php/includes" 

; windows: "\path1;\path2" 
;include_path = ".;c:\php\includes" 

把最后一行的注释去掉,然后把后面路径改成你的pear路径,例如: 
include_path = ".;c:\php\pear\" 
保存php.ini,然后重新启动apache即可。 


--------------- 
         pear命令帮助 
--------------- 
在你的pear目录中可以找到pear.php文件,这是管理pear的命令,在cmd中使用。它的部分命令功能如下: 

安裝: 

自網路安裝某一個pear程式庫: 
  pear install packagename 

下載 packages 但不安裝: 
  pear download packagename 
  pear download-all 

安裝已下載的package: 
  pear install filename.tgz 

列表: 

目前pear網站上所有可取得pear程式庫列表: 
  pear remote-list 

列出已安裝package: 
  pear list 

列出可以升級的package: 
  pear list-upgrades 

更新(升級): 

更新package: 
  pear upgrade packagename 
  pear upgrade-all 

移除: 

刪除已安裝的package: 
  pear uninstall packagename 

---------------- 
          安装新的包 
---------------- 
比如你从http://pear.php.net/package/下载了新的包xxx.tgz。 
把它拷到c:\php\pear\go-pear-bundle目录,然后在cmd中输入: 
pear install xxx.tgz 
就行了,相关文件解压到了c:\php\pear\对应的目录中。 

--------------- 
              实例 
--------------- 
下载pear::html_common 和 pear::html_quickform包,然后安装。 
建个新的php文件,输入代码 

<!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"); 
//建立一个表单对象 
$form = new html_quickform('frmtest', 'post'); 

$form->addelement('header', 'header', '请登录'); 
$form->addelement('text', 'name', '用户名:'); 
$form->addelement('password', 'password', '密码:'); 
$form->addelement('submit', 'submit', '提交'); 
// 输出到浏览器 
$form->display(); 
?> 
</body> 
</html>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网