導航:首頁 > 編程語言 > phpxmlreader安裝

phpxmlreader安裝

發布時間:2022-06-18 09:55:12

A. rpm安裝的lamp,如何可以將配置中的--disable-xmlreader改成啟用

使用選擇server,安裝後php不安裝不完整需要使用yum源更新php
關於源配置找張宴(網路一下)
更新源後
yum install php-gd
yum install php-mysql
這樣版本還是不支持json可以使用老外的源
如果不嫌慢就用這個源php版本很新的
#rpm --import
#vi /etc/yum.repos.d/utterramblings.repo #文中這里是使用nano,但VPS不能啟動nano,用vi代替也是可以的

在打開的文檔中加入下面內容:
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=
enabled=1
gpgcheck=1
gpgkey=

保存。
再次運行下面的命令就可以完成php的升級了
#yum update php

同理,運行下面命令,升級mysql
#yum update mysql

將amp配置為系統服務使用setup命令,非常簡單!

B. PHP網站怎麼連接到資料庫

常規方式

常規方式就是按部就班的讀取文件了。其餘的話和上述方案一致。

// 讀取配置文件內容
$handle = fopen("filepath", "r"); $content = fread($handle, filesize("filepath"));123

PHP解析XML

上述兩種讀取文件,其實都是為了PHP解析XML來做准備的。關於PHP解析XML的方式的博客有很多。方式也有很多,像simplexml,XMLReader,DOM啦等等。但是對於比較小型的xml配置文件,simplexml就足夠了。

配置文件

<?xml version="1.0" encoding="UTF-8" ?><mysql>
<!-- 為防止出現意外,請按照此標准順序書寫.其實也無所謂了 -->
<host>localhost</host>
<user>root</user>
<password>123456</password>
<db>test</db>
<port>3306</port></mysql>12345678910

解析

<?php/**
* 作為解析XML配置文件必備工具
*/class XMLUtil {
public static $dbconfigpath = "./db.config.xml"; public static function getDBConfiguration() {
$dbconfig = array (); try { // 讀取配置文件內容
$handle = fopen(self::$dbconfigpath, "r"); $content = fread($handle, filesize(self::$dbconfigpath)); // 獲取xml文檔根節點,進而獲取相關的資料庫信息
$mysql = simplexml_load_string($content); // 將獲取到的xml節點信息賦值給關聯數組,方便接下來的方法調用
$dbconfig['host'] = $mysql->host; $dbconfig['user'] = $mysql->user; $dbconfig['password'] = $mysql->password; $dbconfig['db'] = $mysql->db; $dbconfig['port'] = $mysql->port; // 將配置信息以關聯數組的形式返回
return $dbconfig;
} catch ( Exception $e ) { throw new RuntimeException ( "<mark>讀取資料庫配置文件信息出錯!</mark><br />" );
} return $dbconfig;
}
}

資料庫連接池

對於PHP程序而言,優化永無止境。而資料庫連接池就在一定程度上起到了優化的作用。其使得對用戶的每一個請求而言,無需每次都像資料庫申請鏈接資源。而是通過已存在的資料庫連接池中的鏈接來返回,從時間上,效率上,都是一個大大的提升。

於是,這里簡單的模擬了一下資料庫連接池的實現。核心在於維護一個「池」。

從池子中取,用畢,歸還給池子。

<?php/**x
* PHP中的資料庫 工具類設計
* 郭璞
* 2016年12月23日
*
**/class DbHelper { private $dbconfig; private $dbpool; public $poolsize; public function __construct($poolsize = 20) { if (! file_exists ( "./utils.php" )) { throw new RuntimeException ( "<mark>utils.php文件丟失,無法進行配置文件的初始化操作!</mark><br />" );
}else {
require './utils.php';
} // 初始化 配置文件信息
$this->dbconfig = XMLUtil::getDBConfiguration (); // 准備好資料庫連接池「偽隊列」
$this->poolsize = $poolsize;
$this->dbpool = array (); for($index = 1; $index <= $this->poolsize; $index ++) {
$conn = mysqli_connect ( $this->dbconfig ['host'], $this->dbconfig ['user'], $this->dbconfig ['password'], $this->dbconfig ['db'] ) or die ( "<mark>連接資料庫失敗!</mark><br />" );
array_push ( $this->dbpool, $conn );
}
} /**
* 從資料庫連接池中獲取一個資料庫鏈接資源
*
* @throws ErrorException
* @return mixed
*/
public function getConn() { if (count ( $this->dbpool ) <= 0) { throw new ErrorException ( "<mark>資料庫連接池中已無鏈接資源,請稍後重試!</mark>" );
} else { return array_pop ( $this->dbpool );
}
} /**
* 將用完的資料庫鏈接資源放回到資料庫連接池
*
* @param unknown $conn
* @throws ErrorException
*/
public function release($conn) { if (count ( $this->dbpool ) >= $this->poolsize) { throw new ErrorException ( "<mark>資料庫連接池已滿</mark><br />" );
} else {
array_push ( $this->dbpool, $conn );
}
}
}

C. PHP開啟XML服務

把這個擴展開啟
extension=php_xmlrpc.dll

D. PHP讀取xml文件

以前做過聯通或電信的service訂購介面,收到的內容就是XML的,需要用到PHP的XML處理功能,你的代碼可以這樣:
<xmp>
<?php

$string=file_get_contents("http://www.orderjiaju.com/zixun/data/rss/3.xml");
if($string!=""):
$xml = new DomDocument('1.0');
$xml->loadXML($string);

//班台
$BanTai=array(
'Title'=>$xml->getElementsByTagName('channel')->item(0)->childNodes->item(1)->nodeValue,
'Link' =>$xml->getElementsByTagName('channel')->item(0)->childNodes->item(3)->nodeValue
);

for($i=0;$i<3;$i++)
{
$Title[]=array(
'Title'=>$xml->getElementsByTagName('item')->item($i)->childNodes->item(1)->nodeValue,
'Link' =>$xml->getElementsByTagName('item')->item($i)->childNodes->item(3)->nodeValue
);
}

print_r($BanTai);
print_r($Title);
endif;
?>
</xmp>

回答補充:

現在你直接,然後執行沒效果嗎?
我這里是可以的呢,測試網址是:service.020i.net/test_xml.php

E. PHP讀寫XML文件

library.xml:
<?xmlversion="1.0"encoding="gb2312"?>
<root>
<groups>
<groupgid="1">super</group>
<groupgid="2">admin</group>
<groupgid="3">change</group>
<groupgid="4">program</group>
</groups>
<users>
<user>
<name>Apache2</name>
<author>PeterWainwright</author>
<publisher>Wrox</publisher>
<group>1</group>
</user>
<user>
<name>AdvancedPHPProgramming</name>
<author>GeorgeSchlossnagle</author>
<publisher>DeveloperLibrary</publisher>
<group>1</group>
<group>3</group>
</user>
<user>
<name>VisualFoxPro6-ProgrammersGuide</name>
<author>EricStroo</author>
<publisher>MicrosoftPress</publisher>
<group>2</group>
</user>
<user>
<name>MasteringJava2</name>
<author>JohnZukowski</author>
<publisher>Sybex</publisher>
<group>4</group>
</user>
</users>
</root>
/**********************************************/
readlibrary.php:

<?php
$xml=newDOMDocument('1.0');
$xml->load('library.xml');
$groups=array();
$XMLGroups=$xml->getElementsByTagName('groups')->item(0);
foreach($XMLGroups->getElementsByTagName('group')as$groupNode){
/*注意我們是如何得到屬性的*/
$gid=$groupNode->getAttribute('gid');
$groups[$gid]=$groupNode->firstChild->nodeValue;
}
?>
<html>
<head>
<title>XMLLibrary</title>
</head>
<body>
<?
foreach($xml->getElementsBytagName('user')as$user):
$name=$user->getElementsByTagName('name')->item(0)->firstChild->nodeValue;
$author=$user->getElementsByTagName('author')->item(0)->firstChild->nodeValue;
$userCategories=$user->getElementsByTagName('group');
$catList='';
foreach($userCategoriesas$category){
$catList.=$groups[$category->firstChild->nodeValue].',';
}
$catList=substr($catList,0,-2);?>
<!--
<div>
<h2><?phpecho($name)?></h2>
<b>Author:</b>:<?phpecho($author)?></br>
<b>group:</b>:<?phpecho($catList)?></br>
</div>
-->
<?php
//echo($name."-".$author."-".$catList."<br>\n");
echo($name."||".$catList."<br>\n");
endforeach;?>
</html>

F. PHP 4.4.9;XML library;GD library;iconv.麻煩給介紹下每個的作用最好有下載地址!

php 一種編程語言 PHP.4.4.9 是它的版本之一 目前已經到了5.*了
GD library,iconv 是php的類庫或者叫函數庫 提供了一些關於處理GD icon功能的函數
XML library:也是PHP的類庫之一了,從字面意思就可以想到是操作XML文件的
簡單些說就是都是些dll文件 最新版本應該是默認就包含有GD library、iconv 這2個DLL 只需要修改配置文件 啟用這2個DLL就可以
XML library好像需要下載安裝,iconv 如果版本很低 可能也需要手動下載安裝

建議樓主是用最新的PHP版本 這樣 大多數就不用安裝 直接擁有這些功能了。

G. php 讀取xml文件的方法

首先 你的 XML文件代碼錯了, 要改下<user> 缺少斜杠 應該是</user>

XML文件代碼:

<?xml version="1.0" encoding="utf-8"?>
<users>
<user id="1" title="哈哈">張三</user>
<user id="2" title="呵呵">李四</user>
</users>

PHP文件代碼:

<?php
// 首先要建一個DOMDocument對象
$xml = new DOMDocument();

// 載入Xml文件
$xml->load('1.xml');

// 獲取所有的user標簽
$user = $xml->getElementsByTagName('user');

// 獲取user標簽的數量
$len = $user->length;

$data = array();

for($i=0;$i<$len;$i++) {
$data[$i] = array();

//第1個 item 代表 user標簽的 順序 第2個 item 代表屬性的順序
$data[$i]['id'] = $user->item($i)->attributes->item(0)->nodeValue;
$data[$i]['title'] = $user->item($i)->attributes->item(1)->nodeValue;
$data[$i]['value'] = $user->item($i)->nodeValue;

}

print_r($data);

?>

H. php 讀取xml 用哪種方法好

1、首先我們做一個簡單的xml文件
<?xml version="1.0 encoding="UTF-8"?><humans><zhangying><name>張映</name><sex>男</sex><old>28</old></zhangying><tank><name>tank</name><sex>男</sex><old>28</old></tank></humans>
2、
php讀取xml的幾種方法:
1)DOMDocument讀取xml
<?php $doc = new DOMDocument(); $doc->load('person.xml'); //讀取xml文件 $humans = $doc->getElementsByTagName( "humans" ); //取得humans標簽的對象數組 foreach( $humans as $human ) { $names = $human->getElementsByTagName( "name" ); //取得name的標簽的對象數組 $name = $names->item(0)->nodeValue; //取得node中的值,如<name> </name> $sexs = $human->getElementsByTagName( "sex" ); $sex = $sexs->item(0)->nodeValue; $olds = $human->getElementsByTagName( "old" ); $old = $olds->item(0)->nodeValue; echo "$name - $sex - $old\n"; } ?>
2)simplexml讀取xml
<?php $xml_array=simplexml_load_file('person.xml'); //將XML中的數據,讀取到數組對象中 foreach($xml_array as $tmp){ echo $tmp->name."-".$tmp->sex."-".$tmp->old."<br>"; } ?>
3)用php正則表達式來記取數據
<?php $xml = ""; $f = fopen('person.xml', 'r'); while( $data = fread( $f, 4096 ) ) { $xml .= $data; } fclose( $f ); // 上面讀取數據 preg_match_all( "/\<humans\>(.*?)\<\/humans\>/s", $xml, $humans ); //匹配最外層標簽裡面的內容 foreach( $humans[1] as $k=>$human ) { preg_match_all( "/\<name\>(.*?)\<\/name\>/", $human, $name ); //匹配出名字 preg_match_all( "/\<sex\>(.*?)\<\/sex\>/", $human, $sex ); //匹配出性別 preg_match_all( "/\<old\>(.*?)\<\/old\>/", $human, $old ); //匹配出年齡 } foreach($name[1] as $key=>$val){ echo $val." - ".$sex[$key][1]." - ".$old[$key][1]."<br>" ; } ?>
4)xmlreader來讀取xml數據
<?php $reader = new XMLReader(); $reader->open('person.xml'); //讀取xml數據 $i=1; while ($reader->read()) { //是否讀取 if ($reader->nodeType == XMLReader::TEXT) { //判斷node類型 if($i%3){ echo $reader->value; //取得node的值 }else{ echo $reader->value."<br>" ; } $i++; } } ?>

I. php網站程序用什麼資料庫

您好,你的問題,我之前好像也遇到過,以下是我原來的解決思路和方法,希望能幫助到你,若有錯誤,還望見諒!展開全部
常規方式
常規方式就是按部就班的讀取文件了。其餘的話和上述方案一致。
// 讀取配置文件內容
$handle = fopen("filepath", "r"); $content = fread($handle, filesize("filepath"));123
PHP解析XML
上述兩種讀取文件,其實都是為了PHP解析XML來做准備的。關於PHP解析XML的方式的博客有很多。方式也有很多,像simplexml,XMLReader,DOM啦等等。但是對於比較小型的xml配置文件,simplexml就足夠了。
配置文件
<?xml version="1.0" encoding="UTF-8" ?><mysql>
<!-- 為防止出現意外,請按照此標准順序書寫.其實也無所謂了 -->
<host>localhost</host>
<user>root</user>
<password>123456</password>
<db>test</db>
<port>3306</port></mysql>12345678910
解析非常感謝您的耐心觀看,如有幫助請採納,祝生活愉快!謝謝!

J. 該函數需要 PHP 支持 XML,這該如何處理

閱讀全文

與phpxmlreader安裝相關的資料

熱點內容
javalistclear 瀏覽:605
哪個app上民宿多靠譜 瀏覽:825
重慶伺服器租用哪裡有雲伺服器 瀏覽:453
土星模擬器文件夾 瀏覽:902
文件夾文件袋文件盒 瀏覽:695
雲伺服器打開f8指令 瀏覽:243
盈透證券加密幣 瀏覽:72
阿里雲伺服器初始密碼怎麼修改 瀏覽:266
伺服器怎麼設定公用網路 瀏覽:99
程序員自己嘗尿檢測出糖尿病 瀏覽:593
列印添加pdf 瀏覽:932
蘋果解壓專家賬號 瀏覽:842
度曉曉app為什麼關閑 瀏覽:228
net文件是偽編解碼嗎 瀏覽:149
伴隨矩陣的matlab編程 瀏覽:63
單片機和h橋是什麼意思 瀏覽:314
51單片機光控設計論文 瀏覽:653
渦旋式壓縮機無油 瀏覽:731
企業網搭建及應用pdf 瀏覽:744
symanteclinux 瀏覽:879