首頁 php教程 php手册 用php5轻松解析xml

用php5轻松解析xml

Jun 21, 2016 am 09:06 AM
gt lt name this

php5|xml

用sax方式的时候,要自己构建3个函数, 而且要直接用这三的函数来返回数据, 要求较强的逻辑. 在处理不同结构的xml的时候, 还要重新进行构造这三个函数,麻烦!

用dom方式,倒是好些,但是他把每个节点都看作是一个node, 操作起来要写好多的代码, 麻烦!

网上有好多的开源的xml解析的类库, 以前看过几个, 但是心里总是觉得不踏实, 感觉总是跟在别人的屁股后面.

这几天在搞java, 挺累的, 所以决定换换脑袋, 写点php代码, 为了防止以后xml解析过程再令我犯难, 就花了一天的时间写了下面一个xml解析的类, 于是就有了下面的东西,

实现方式是通过包装"sax方式的解析结果"来实现的. 总的来说,对于我个人来说挺实用的,性能也还可以,基本上可以完成大多数的处理要求。

功能:
1\ 对基本的xml文件的节点进行 查询 / 添加 / 修改 / 删除 工作.
2\ 导出xml文件的所有数据到一个数组里面.
3\ 整个设计采用了oo方式,在操作结果集的时候, 使用方法类似于dom

缺点:
1\ 每个节点最好都带有一个id(看后面的例子), 每个“节点名字”=“节点的标签_节点的id”,如果这个id值没有设置,程序将自动给他产生一个id,这个id就是这个节点在他的上级节点中的位置编号,从0开始。
2\ 查询某个节点的时候可以通过用“|”符号连接“节点名字”来进行。这些“节点名字”都是按顺序写好的上级节点的名字。

使用说明:
运行下面的例子,在执行结果页面上可以看到函数的使用说明

代码是通过php5来实现的,在php4中无法正常运行。

由于刚刚写完,所以没有整理文档,下面的例子演示的只是一部分的功能,代码不是很难,要是想知道更多的功能,可以研究研究源代码。

目录结构:

      test.php      test.xml      xml / SimpleDocumentBase.php      xml / SimpleDocumentNode.php      xml / SimpleDocumentRoot.php      xml / SimpleDocumentParser.php
登入後複製
文件:test.xml
<?xml version="1.0" encoding="GB2312"?><br><shop><br> <name>华联</name><br> <address>北京长安街-9999号</address>
<br> <desc>连锁超市</desc><br> <cat id="food"><br>  <goods id="food11"><br>   <name>food11</name><br>   <price>12.90</price><br>  </goods><br>  <goods id="food12"><br>   <name>food12</name><br>   <price>22.10</price><br>   <desc creator="hahawen">好东西推荐</desc><br>  </goods><br> </cat><br> <cat><br>  <goods id="tel21"><br>   <name>tel21</name><br>   <price>1290</price><br>  </goods><br> </cat><br> <cat id="coat"><br>  <goods id="coat31"><br>   <name>coat31</name><br>   <price>112</price><br>  </goods><br>  <goods id="coat32"><br>   <name>coat32</name><br>   <price>45</price><br>  </goods><br> </cat><br> <special id="hot"><br>  <goods><br>   <name>hot41</name><br>   <price>99</price><br>  </goods><br> </special><br></shop>
登入後複製
文件:test.php
<?php 
登入後複製

require_once "xml/SimpleDocumentParser.php";
require_once "xml/SimpleDocumentBase.php";
require_once "xml/SimpleDocumentRoot.php";
require_once "xml/SimpleDocumentNode.php";

$test = new SimpleDocumentParser();
$test->parse("test.xml");
$dom = $test->getSimpleDocument();

echo "

";<p>echo "</p><hr><font color="red">";<br>echo "下面是通过函数getSaveData()返回的整个xml数据的数组";<br>echo "</font><hr>";<br>print_r($dom->getSaveData());<p>echo "</p><hr><font color="red">";<br>echo "下面是通过setValue()函数,给给根节点添加信息,添加后显示出结果xml文件的内容";<br>echo "</font><hr>";<br>$dom->setValue("telphone", "123456789");<br>echo htmlspecialchars($dom->getSaveXml());<p>echo "</p><hr><font color="red">";<br>echo "下面是通过getNode()函数,返回某一个分类下的所有商品的信息";<br>echo "</font><hr>";<br>$obj = $dom->getNode("cat_food");<br>$nodeList = $obj->getNode();<br>foreach($nodeList as $node){<br>$data = $node->getValue();<br>echo "<font color="red">商品名:".$data[name]."</font><br>";<br>print_R($data);<br>print_R($node->getAttribute());<br>}<p>echo "</p><hr><font color="red">";<br>echo "下面是通过findNodeByPath()函数,返回某一商品的信息";<br>echo "</font><hr>";<br>$obj = $dom->findNodeByPath("cat_food|goods_food11");<br>if(!is_object($obj)){<br>echo "该商品不存在";<br>}else{<br>$data = $obj->getValue();<br>echo "<font color="red">商品名:".$data[name]."</font><br>";<br>print_R($data);<br>print_R($obj->getAttribute());<br>}<p>echo "</p><hr><font color="red">";<br>echo "下面是通过setValue()函数,给商品\"food11\"添加属性, 然后显示添加后的结果";<br>echo "</font><hr>";<br>$obj = $dom->findNodeByPath("cat_food|goods_food11");<br>$obj->setValue("leaveword", array("value"=>"这个商品不错", "attrs"=>array("author"=>"hahawen", "date"=>date('Y-m-d'))));<br>echo htmlspecialchars($dom->getSaveXml());<p>echo "</p><hr><font color="red">";<br>echo "下面是通过removeValue()/removeAttribute()函数,给商品\"food11\"改变和删除属性, 然后显示操作后的结果";<br>echo "</font><hr>";<br>$obj = $dom->findNodeByPath("cat_food|goods_food12");<br>$obj->setValue("name", "new food12");<br>$obj->removeValue("desc");<br>echo htmlspecialchars($dom->getSaveXml());<p>echo "</p><hr><font color="red">";<br>echo "下面是通过createNode()函数,添加商品, 然后显示添加后的结果";<br>echo "</font><hr>";<br>$obj = $dom->findNodeByPath("cat_food");<br>$newObj = $obj->createNode("goods", array("id"=>"food13"));<br>$newObj->setValue("name", "food13");<br>$newObj->setValue("price", 100);<br>echo htmlspecialchars($dom->getSaveXml());<p>echo "</p><hr><font color="red">";<br>echo "下面是通过removeNode()函数,删除商品, 然后显示删除后的结果";<br>echo "</font><hr>";<br>$obj = $dom->findNodeByPath("cat_food");<br>$obj->removeNode("goods_food12");<br>echo htmlspecialchars($dom->getSaveXml());<br>?> <pre class="brush:php;toolbar:false">
登入後複製
文件:SimpleDocumentParser.php
<?php /** *========================================================= * * @author     hahawen(大龄青年)   * @since      2004-12-04 * @copyright  Copyright (c) 2004, NxCoder Group * *========================================================= *//** * class SimpleDocumentParser * use SAX parse xml file, and build SimpleDocumentObject * all this pachage's is work for xml file, and method is action as DOM. * * @package SmartWeb.common.xml * @version 1.0 */class SimpleDocumentParser{ private $domRootObject = null; private $currentNO = null; private $currentName = null; private $currentValue = null; private $currentAttribute = null; public function getSimpleDocument() {     return $this->domRootObject; } public function parse($file) {        $xmlParser = xml_parser_create();     xml_parser_set_option($xmlParser,XML_OPTION_CASE_FOLDING, 0);     xml_parser_set_option($xmlParser,XML_OPTION_SKIP_WHITE, 1);     xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'UTF-8');     xml_set_object($xmlParser, $this);     xml_set_element_handler($xmlParser, "startElement", "endElement");     xml_set_character_data_handler($xmlParser, "characterData");        if (!xml_parse($xmlParser, file_get_contents($file)))            die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xmlParser)), xml_get_current_line_number($xmlParser)));     xml_parser_free($xmlParser); } private function startElement($parser, $name, $attrs) {        $this->currentName = $name;        $this->currentAttribute = $attrs;        if($this->currentNO == null)        {         $this->domRootObject = new SimpleDocumentRoot($name);         $this->currentNO = $this->domRootObject;        }        else        {         $this->currentNO = $this->currentNO->createNode($name, $attrs);        } }    private function endElement($parser, $name)    {        if($this->currentName==$name)        {         $seq = $this->currentNO->getSeq();
         $this->currentNO = $this->currentNO->getPNodeObject();
         $tag = $this->currentNO->getNodeName($seq);
登入後複製
         if($this->currentAttribute!=null && sizeof($this->currentAttribute)>0)          $this->currentNO->setValue($name, array('value'=>$this->currentValue, 'attrs'=>$this->currentAttribute));         else                $this->currentNO->setValue($name, $this->currentValue);            $this->currentNO->removeNode($tag);        }        else        {      $this->currentNO = (is_a($this->currentNO, 'SimpleDocumentRoot'))? null: $this->currentNO->getPNodeObject();        } } private function characterData($parser, $data) {        $this->currentValue = iconv('UTF-8', 'GB2312', $data); } function __destruct() {     unset($this->domRootObject); }}?>
登入後複製
文件:SimpleDocumentBase.php
<?php /** *========================================================= * * @author     hahawen(大龄青年)   * @since      2004-12-04 * @copyright  Copyright (c) 2004, NxCoder Group * *========================================================= *//** * abstract class SimpleDocumentBase * base class for xml file parse * all this pachage's is work for xml file, and method is action as DOM. * * 1\ add/update/remove data of xml file. * 2\ explode data to array. * 3\ rebuild xml file * * @package SmartWeb.common.xml * @abstract * @version 1.0 */abstract class SimpleDocumentBase{ private $nodeTag = null; private $attributes = array(); private $values = array(); private $nodes = array();    function __construct($nodeTag)    {        $this->nodeTag = $nodeTag;    }    public function getNodeTag()    {     return $this->nodeTag;    }    public function setValues($values){     $this->values = $values;    }    public function setValue($name, $value)    {     $this->values[$name] = $value;    }    public function getValue($name=null)    {     return $name==null? $this->values: $this->values[$name];    }    public function removeValue($name)    {     unset($this->values["$name"]);    }    public function setAttributes($attributes){        $this->attributes = $attributes;    }    public function setAttribute($name, $value)    {     $this->attributes[$name] = $value;    }    public function getAttribute($name=null)    {        return $name==null? $this->attributes: $this->attributes[$name];    }    public function removeAttribute($name)    {     unset($this->attributes["$name"]);    }    public function getNodesSize()    {        return sizeof($this->nodes);    }    protected function setNode($name, $nodeId)    {     $this->nodes[$name] = $nodeId;    }    public abstract function createNode($name, $attributes);    public abstract function removeNode($name);    public abstract function getNode($name=null);    protected function getNodeId($name=null)    {     return $name==null? $this->nodes: $this->nodes[$name];    }
登入後複製
    public function getNodeName($id)<br>    {<br>     $tmp = array_flip($this->nodes);<br>     return $tmp[$id];<br>    }    protected function createNodeByName($rootNodeObj, $name, $attributes, $pId)    {        $tmpObject = $rootNodeObj->createNodeObject($pId, $name, $attributes);        $key = isset($attributes[id])? $name.'_'.$attributes[id]: $name.'_'.$this->getNodesSize();        $this->setNode($key, $tmpObject->getSeq());     return $tmpObject;    }    protected function removeNodeByName($rootNodeObj, $name)    {        $rootNodeObj->removeNodeById($this->getNodeId($name));        if(sizeof($this->nodes)==1)            $this->nodes = array();     else      unset($this->nodes[$name]);    }    protected function getNodeByName($rootNodeObj, $name=null)    {     if($name==null)     {            $tmpList = array();            $tmpIds = $this->getNodeId();            foreach($tmpIds as $key=>$id)             $tmpList[$key] = $rootNodeObj->getNodeById($id);            return $tmpList;     }     else     {      $id = $this->getNodeId($name);      if($id===null)      {             $tmpIds = $this->getNodeId();             foreach($tmpIds as $tkey=>$tid)             {              if(strpos($key, $name)==0)              {               $id = $tid;               break;              }             }      }      return $rootNodeObj->getNodeById($id);     }    }    public function findNodeByPath($path)    {     $pos = strpos($path, '|');     if($posgetNode($path);        }        else        {         $tmpObj = $this->getNode(substr($path, 0, $pos));         return is_object($tmpObj)? $tmpObj->findNodeByPath(substr($path, $pos+1)): null;        }    }    public function getSaveData()    {        $data = $this->values;        if(sizeof($this->attributes)>0)         $data[attrs] = $this->attributes;        $nodeList = $this->getNode();        if($nodeList==null)         return $data;        foreach($nodeList as $key=>$node)        {         $data[$key] = $node->getSaveData();        }     return $data;    }    public function getSaveXml($level=0)    {     $prefixSpace = str_pad("", $level, "\t");     $str = "$prefixSpacenodeTag";        foreach($this->attributes as $key=>$value)         $str .= " $key=\"$value\"";        $str .= ">\r\n";        foreach($this->values as $key=>$value){            if(is_array($value))            {                $str .= "$prefixSpace\t$attvalue)                 $str .= " $attkey=\"$attvalue\"";                $tmpStr = $value[value];            }            else            {             $str .= "$prefixSpace\t\r\n": ">$tmpStr$key>\r\n";        }        foreach($this->getNode() as $node)         $str .= $node->getSaveXml($level+1)."\r\n";     $str .= "$prefixSpace$this->nodeTag>";     return $str;    }    function __destruct()    {     unset($this->nodes, $this->attributes, $this->values);    }}?>
登入後複製
文件:SimpleDocumentRoot.php
<?php /** *========================================================= * * @author     hahawen(大龄青年)   * @since      2004-12-04 * @copyright  Copyright (c) 2004, NxCoder Group * *========================================================= *//** * class SimpleDocumentRoot * xml root class, include values/attributes/subnodes. * all this pachage's is work for xml file, and method is action as DOM. * * @package SmartWeb.common.xml * @version 1.0 */class SimpleDocumentRoot extends SimpleDocumentBase{ private $prefixStr = ''; private $nodeLists = array(); function __construct($nodeTag) {        parent::__construct($nodeTag); }    public function createNodeObject($pNodeId, $name, $attributes)    {     $seq = sizeof($this->nodeLists);     $tmpObject = new SimpleDocumentNode($this, $pNodeId, $name, $seq);     $tmpObject->setAttributes($attributes);     $this->nodeLists[$seq] = $tmpObject;     return $tmpObject;    }    public function removeNodeById($id)    {        if(sizeof($this->nodeLists)==1)            $this->nodeLists = array();     else      unset($this->nodeLists[$id]);    }    public function getNodeById($id)    {     return $this->nodeLists[$id];    }    public function createNode($name, $attributes)    {        return $this->createNodeByName($this, $name, $attributes, -1);    }    public function removeNode($name)    {        return $this->removeNodeByName($this, $name);    }    public function getNode($name=null)    {        return $this->getNodeByName($this, $name);    }    public function getSaveXml()    {     $prefixSpace = "";     $str = $this->prefixStr."\r\n";     return $str.parent::getSaveXml(0);    }}?>
登入後複製
文件:SimpleDocumentNode.php
<?php /** *========================================================= * * @author     hahawen(大龄青年)   * @since      2004-12-04 * @copyright  Copyright (c) 2004, NxCoder Group * *========================================================= *//** * class SimpleDocumentNode * xml Node class, include values/attributes/subnodes. * all this pachage's is work for xml file, and method is action as DOM. * * @package SmartWeb.common.xml * @version 1.0 */class SimpleDocumentNode extends SimpleDocumentBase{ private $seq = null; private $rootObject = null;    private $pNodeId = null;    function __construct($rootObject, $pNodeId, $nodeTag, $seq)    {     parent::__construct($nodeTag);        $this->rootObject = $rootObject;        $this->pNodeId = $pNodeId;        $this->seq = $seq;    }    public function getPNodeObject()    {     return ($this->pNodeId==-1)? $this->rootObject: $this->rootObject->getNodeById($this->pNodeId);    }    public function getSeq(){     return $this->seq;    }    public function createNode($name, $attributes)    {        return $this->createNodeByName($this->rootObject, $name, $attributes, $this->getSeq());    }    public function removeNode($name)    {        return $this->removeNodeByName($this->rootObject, $name);    }    public function getNode($name=null)    {        return $this->getNodeByName($this->rootObject, $name);    }}?>
登入後複製
下面是例子运行对结果:
<hr><font color="red">下面是通过函数getSaveData()返回的整个xml数据的数组</font><hr>Array(    [name] => 华联    [address] => 北京长安街-9999号    [desc] => 连锁超市    [cat_food] => Array        (            [attrs] => Array                (                    [id] => food                )            [goods_food11] => Array                (                    [name] => food11                    [price] => 12.90                    [attrs] => Array                        (                            [id] => food11                        )                )            [goods_food12] => Array                (                    [name] => food12                    [price] => 22.10                    [desc] => Array                        (                            [value] => 好东西推荐                            [attrs] => Array                                (                                    [creator] => hahawen                                )                        )                    [attrs] => Array                        (                            [id] => food12                        )                )        )    [cat_1] => Array        (            [goods_tel21] => Array                (                    [name] => tel21                    [price] => 1290                    [attrs] => Array                        (                            [id] => tel21                        )                )        )    [cat_coat] => Array        (            [attrs] => Array                (                    [id] => coat                )            [goods_coat31] => Array                (                    [name] => coat31                    [price] => 112                    [attrs] => Array                        (                            [id] => coat31                        )                )            [goods_coat32] => Array                (                    [name] => coat32                    [price] => 45                    [attrs] => Array                        (                            [id] => coat32                        )                )        )    [special_hot] => Array        (            [attrs] => Array                (                    [id] => hot                )            [goods_0] => Array                (                    [name] => hot41                    [price] => 99                )        ))<hr><font color="red">下面是通过setValue()函数,给给根节点添加信息,添加后显示出结果xml文件的内容</font><hr><?xml version="1.0" encoding="GB2312" ?><shop> <name>华联</name> <address>北京长安街-9999号</address> <desc>连锁超市</desc> <telphone>123456789</telphone> <cat id="food">  <goods id="food11">   <name>food11</name>   <price>12.90</price>  </goods>  <goods id="food12">   <name>food12</name>   <price>22.10</price>   <desc creator="hahawen">好东西推荐</desc>  </goods> </cat> <cat>  <goods id="tel21">   <name>tel21</name>   <price>1290</price>  </goods> </cat> <cat id="coat">  <goods id="coat31">   <name>coat31</name>   <price>112</price>  </goods>  <goods id="coat32">   <name>coat32</name>   <price>45</price>  </goods> </cat> <special id="hot">  <goods>   <name>hot41</name>   <price>99</price>  </goods> </special></shop><hr><font color="red">下面是通过getNode()函数,返回某一个分类下的所有商品的信息</font><hr><font color="red">商品名:food11</font><br>Array(    [name] => food11    [price] => 12.90)Array(    [id] => food11)<font color="red">商品名:food12</font><br>Array(    [name] => food12    [price] => 22.10    [desc] => Array        (            [value] => 好东西推荐            [attrs] => Array                (                    [creator] => hahawen                )        ))Array(    [id] => food12)<hr><font color="red">下面是通过findNodeByPath()函数,返回某一商品的信息</font><hr><font color="red">商品名:food11</font><br>Array(    [name] => food11    [price] => 12.90)Array(    [id] => food11)<hr><font color="red">下面是通过setValue()函数,给商品"food11"添加属性, 然后显示添加后的结果</font><hr><?xml version="1.0" encoding="GB2312" ?><shop> <name>华联</name> <address>北京长安街-9999号</address> <desc>连锁超市</desc> <telphone>123456789</telphone> <cat id="food">  <goods id="food11">   <name>food11</name>   <price>12.90</price>   <leaveword author="hahawen" date="2004-12-05">这个商品不错</leaveword>  </goods>  <goods id="food12">   <name>food12</name>   <price>22.10</price>   <desc creator="hahawen">好东西推荐</desc>  </goods> </cat> <cat>  <goods id="tel21">   <name>tel21</name>   <price>1290</price>  </goods> </cat> <cat id="coat">  <goods id="coat31">   <name>coat31</name>   <price>112</price>  </goods>  <goods id="coat32">   <name>coat32</name>   <price>45</price>  </goods> </cat> <special id="hot">  <goods>   <name>hot41</name>   <price>99</price>  </goods> </special></shop><hr><font color="red">下面是通过removeValue()/removeAttribute()函数,给商品"food11"改变和删除属性, 然后显示操作后的结果</font><hr><?xml version="1.0" encoding="GB2312" ?><shop> <name>华联</name> <address>北京长安街-9999号</address> <desc>连锁超市</desc> <telphone>123456789</telphone> <cat id="food">  <goods id="food11">   <name>food11</name>   <price>12.90</price>   <leaveword author="hahawen" date="2004-12-05">这个商品不错</leaveword>  </goods>  <goods id="food12">   <name>new food12</name>   <price>22.10</price>  </goods> </cat> <cat>  <goods id="tel21">   <name>tel21</name>   <price>1290</price>  </goods> </cat> <cat id="coat">  <goods id="coat31">   <name>coat31</name>   <price>112</price>  </goods>  <goods id="coat32">   <name>coat32</name>   <price>45</price>  </goods> </cat> <special id="hot">  <goods>   <name>hot41</name>   <price>99</price>  </goods> </special></shop><hr><font color="red">下面是通过createNode()函数,添加商品, 然后显示添加后的结果</font><hr><?xml version="1.0" encoding="GB2312" ?><shop> <name>华联</name> <address>北京长安街-9999号</address> <desc>连锁超市</desc> <telphone>123456789</telphone> <cat id="food">  <goods id="food11">   <name>food11</name>   <price>12.90</price>   <leaveword author="hahawen" date="2004-12-05">这个商品不错</leaveword>  </goods>  <goods id="food12">   <name>new food12</name>   <price>22.10</price>  </goods>  <goods id="food13">   <name>food13</name>   <price>100</price>  </goods> </cat> <cat>  <goods id="tel21">   <name>tel21</name>   <price>1290</price>  </goods> </cat> <cat id="coat">  <goods id="coat31">   <name>coat31</name>   <price>112</price>  </goods>  <goods id="coat32">   <name>coat32</name>   <price>45</price>  </goods> </cat> <special id="hot">  <goods>   <name>hot41</name>   <price>99</price>  </goods> </special></shop><hr><font color="red">下面是通过removeNode()函数,删除商品, 然后显示删除后的结果</font><hr><?xml version="1.0" encoding="GB2312" ?><shop> <name>华联</name> <address>北京长安街-9999号</address> <desc>连锁超市</desc> <telphone>123456789</telphone> <cat id="food">  <goods id="food11">   <name>food11</name>   <price>12.90</price>   <leaveword author="hahawen" date="2004-12-05">这个商品不错</leaveword>  </goods>  <goods id="food13">   <name>food13</name>   <price>100</price>  </goods> </cat> <cat>  <goods id="tel21">   <name>tel21</name>   <price>1290</price>  </goods> </cat> <cat id="coat">  <goods id="coat31">   <name>coat31</name>   <price>112</price>  </goods>  <goods id="coat32">   <name>coat32</name>   <price>45</price>  </goods> </cat> <special id="hot">  <goods>   <name>hot41</name>   <price>99</price>  </goods> </special></shop>
登入後複製



本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

華為GT3 Pro和GT4的差異是什麼? 華為GT3 Pro和GT4的差異是什麼? Dec 29, 2023 pm 02:27 PM

許多用戶在選擇智慧型手錶的時候都會選擇的華為的品牌,其中華為GT3pro和GT4都是非常熱門的選擇,不少用戶都很好奇華為GT3pro和GT4有什麼區別,下面就給大家介紹一下二者。華為GT3pro和GT4有什麼差別一、外觀GT4:46mm和41mm,材質是玻璃鏡板+不鏽鋼機身+高分纖維後殼。 GT3pro:46.6mm和42.9mm,材質是藍寶石玻璃鏡+鈦金屬機身/陶瓷機身+陶瓷後殼二、健康GT4:採用最新的華為Truseen5.5+演算法,結果會更加的精準。 GT3pro:多了ECG心電圖和血管及安

修復:截圖工具在 Windows 11 中不起作用 修復:截圖工具在 Windows 11 中不起作用 Aug 24, 2023 am 09:48 AM

為什麼截圖工具在Windows11上不起作用了解問題的根本原因有助於找到正確的解決方案。以下是截圖工具可能無法正常工作的主要原因:對焦助手已開啟:這可以防止截圖工具開啟。應用程式損壞:如果截圖工具在啟動時崩潰,則可能已損壞。過時的圖形驅動程式:不相容的驅動程式可能會幹擾截圖工具。來自其他應用程式的干擾:其他正在運行的應用程式可能與截圖工具衝突。憑證已過期:升級過程中的錯誤可能會導致此issu簡單的解決方案這些適合大多數用戶,不需要任何特殊的技術知識。 1.更新視窗與Microsoft應用程式商店應用程

如何修復無法連線到iPhone上的App Store錯誤 如何修復無法連線到iPhone上的App Store錯誤 Jul 29, 2023 am 08:22 AM

第1部分:初始故障排除步驟檢查蘋果的系統狀態:在深入研究複雜的解決方案之前,讓我們先從基礎知識開始。問題可能不在於您的設備;蘋果的伺服器可能會關閉。造訪Apple的系統狀態頁面,查看AppStore是否正常運作。如果有問題,您所能做的就是等待Apple修復它。檢查您的網路連接:確保您擁有穩定的網路連接,因為「無法連接到AppStore」問題有時可歸因於連接不良。嘗試在Wi-Fi和行動數據之間切換或重置網路設定(「常規」>「重置」>「重置網路設定」>設定)。更新您的iOS版本:

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

聊聊Vue2為什麼能透過this存取各種選項中屬性 聊聊Vue2為什麼能透過this存取各種選項中屬性 Dec 08, 2022 pm 08:22 PM

這篇文章帶大家解讀vue原始碼,來介紹一下Vue2中為什麼可以使用 this 存取各種選項中的屬性,希望對大家有幫助!

一篇搞懂this指向,追趕70%的前端人 一篇搞懂this指向,追趕70%的前端人 Sep 06, 2022 pm 05:03 PM

同事因為this指向的問題卡住的bug,vue2的this指向問題,使用了箭頭函數,導致拿不到對應的props。當我跟他介紹的時候他竟然不知道,隨後也刻意的看了一下前端交流群,至今最起碼還有70%以上的前端程式設計師搞不明白,今天給大家分享一下this指向,如果啥都沒學會,請給我一個大嘴巴子。

watch4pro好還是gt好 watch4pro好還是gt好 Sep 26, 2023 pm 02:45 PM

watch4pro和gt各自具有不使用的特點和適用場景,如果注重功能的全面性、高性能和時尚外觀,同時願意承擔較高的價格,那麼Watch 4 Pro可能更適合。如果對功能要求不高,更注重電池續航力和價格的合理性,那麼GT系列可能更適合。最終的選擇應根據個人需求、預算和喜好來決定,建議在購買前仔細考慮自己的需求,並參考各種產品的評測和比較,以做出更明智的選擇。

如何使用 iPadOS 17.4 優化 iPad 電池壽命 如何使用 iPadOS 17.4 優化 iPad 電池壽命 Mar 21, 2024 pm 10:31 PM

如何使用iPadOS17.4优化iPad电池寿命延长电池续航时间是移动设备体验的关键,iPad是一个很好的例子。如果您觉得iPad电池消耗速度过快,不用担心,在iPadOS17.4中有许多技巧和调整可以显著延长设备的运行时间。本深入指南的目标不仅仅是提供信息,而是改变您使用iPad的方式,增强您的整体电池管理,并确保您可以在无需充电的情况下更长时间地依赖您的设备。通过采用此处概述的做法,您朝着更高效、更谨慎地使用技术迈出了一步,这些技术是根据您的个人需求和使用模式量身定制的。识别主要的能量消耗者

See all articles