PHP: Kua utaina a SimpleXML?

Depositphotos 11843590 s

He ruarua monomai kua hangaia e au hei PHP5 + me SimpleXML. Ko te SimpleXML he maama ake, he pai ake te whakamahi i te whakahoki i nga whakautu XML mai i APIs. Ko te raru, ka tae au ki etahi imeera i te ra, i te wiki ranei, e paatai ​​ana ahau he aha te take kaore e taea e te kaiwhakamahi te uta i te hotaka, ana he he.

Te ahua, ko aku panui kei runga i nga monomai me nga whaarangi kaupapa kaore i ranea, no reira i mahia e au te mea tika me te taapiri i nga mahi ki nga taapiri e rua hei tirotiro kua utaina te toronga SimpleXML

Mahi PHP ki te tirotiro i te toronga SimpleXML kua utaina:

mahi isSimpleXMLLoaded () {$ array = array (); $ array = get_loaded_xtensions (); $ hua = teka; mua ($ ngohi hei $ i => $ uara) {mena (strtolower ($ uara) == "simplexml") {$ hua = pono; }} whakahoki $ hua; }

Na, i roto i nga mahi e whakamahi ana i te SimpleXML, ka taea e au te whakarite kia utaina i mua i taku whakamatautauranga i te waea SimpleXML. Mena

ki te (! isSimpleXMLLoaded ()) {reo "Me manaaki to papaanga i tetahi atu waahi!"; hokinga; }

Kei te mohio au he kaiako PHP taku ka titiro ki taku tuhinga, whakamohio mai me pehea taku mahi! Kua tukuna e au he whakahou iti ki nga Mono e rua hei whakamahi i tenei tikanga.

6 Comments

  1. 1

    Kia ora Doug,

    I kite ahau i tetahi pepeke kaore pea e hapa.

    mena ($ uara = "SimpleXML") {$ hua = pono; }

    me waiho

    mena ($ uara == “SimpleXML”) {$ hua = pono; }

    Ahakoa mo te ahuru. He pai ki ahau.

    mena ka (strtolower ($ uara) == “simplexml”) {$ hua = pono; }

    Ka taea hoki te whakamahi i te 'extension_loaded' e tango ana i te ingoa toronga ki te tirotiro (he take tairongo).

    $ utaina = toronga_mihi (“SimpleXML”);

    Whakahoki TIKA, HU ranei.

    PS Kaua e inu i te kawhe, engari ka hoatu pea e au he paatene 'hokona mai he pouaka pounamu' 🙂

    • 2

      Tiikina te paatene totika ake, Nick! He kaiwhakaora ora koe! He aha te mea rorirori na (tangohia ko te strtolower), Ko taku tauira tauira kei te whakahaere me te whakamahi i te arotake tika. Kua roa pea no te mea i te wa i tukuna ai e au, kua raru ahau!

      Kua whakarerekehia e ahau te waehere me te pou o te tuhinga. Patai: He painga tetahi mo tetahi? Te mana'o nei au ko te toronga_ i utaina he maama me te tere o te whakahaere i tenei!

      Nga mihi Nick!

  2. 4

    yum whakauru php55-xml.x86_64 ki te whakauru i te simpleXML mo te php 5.5.11

    Whakawhiti Whakahaere
    Kei te whakauru: php55-xml-5.5.11-1.el6.x86_64 1/1
    Manatoko: php55-xml-5.5.11-1.el6.x86_64 1/1

    kātahi ka whakauruhia
    /usr/lib64/php/modules/simplexml.so

  3. 5

He aha koutou whakaaro?

Whakamahia ai e tenei pae i te Akismet hei whakaiti i te mokowhiti. Akohia te tukatuka o to raraunga korero.