PHP: Kodi SimpleXML Yonyamula?

Zithunzi za Depositph 11843590 s

Pali mapulagini angapo omwe ndapanga omwe amafuna PHP5 + ndi ZambiriXML. SimpleXML ndi njira yosavuta kwambiri yochitira bwino mayankho a XML kuchokera APIs. Vuto, komabe, ndiloti ndimatha kulandira maimelo angapo tsiku kapena sabata ndikundifunsa chifukwa chomwe wogwiritsa ntchitoyo sangatenge pulogalamuyi ndipo zimabweretsa zolakwika.

Mwachiwonekere, zidziwitso zanga pamapulagini komanso patsamba la projekiti sizinali zokwanira, chifukwa chake ndidachita zoyenera ndikuwonjezera magwiridwe antchito pamapulagini onse awiri kuti nditsimikizire kuti kutambasula kwa SimpleXML kwadzaza.

Ntchito ya PHP kuti muwone kufalikira kwa SimpleXML kwadzaza:

ntchito isSimpleXMLLoaded () {$ array = array (); $ zambiri = get_loaded_extensions (); $ zotsatira = zabodza; chithunzi ($ array as $ i => $ value) {if (strtolower ($ value) == "simplexml") {$ result = true; }} bwezerani zotsatira za $; }

Tsopano, mkati mwa ntchito zomwe zimagwiritsa ntchito SimpleXML, nditha kungowonetsetsa kuti zanyamula ndisanayese kuyimba kwa SimpleXML. Ngati

ngati (! isSimpleXMLLoaded ()) {echo "Sungani tsamba lanu kwina!"; kubwerera; }

Ndikudziwa kuti ndili ndi ma PHP gurus omwe amayang'anira blog yanga, ndidziwitseni momwe ndidapangira! Ndatulutsa zosintha zazing'ono ku Mapulagini onse awiri kuti mugwiritse ntchito njirayi.

6 Comments

  1. 1

    Wawa Doug,

    Ndinawona kachilombo kamodzi komwe sikungabweretse vuto.

    ngati ($ value = “SimpleXML”) {$ result = zoona; }

    ziyenera kukhala

    ngati ($ value == "SimpleXML") {$ result = zowona; }

    Ngakhale chifukwa cha chitetezo. Ndimakonda.

    ngati (strtolower ($ value) == "simplexml") {$ result = zowona; }

    Muthanso kugwiritsa ntchito 'extension_loaded' yomwe imatenga dzina lowonjezera kuti muwone (zovuta).

    $ yodzaza = yowonjezera_kutsitsidwa ("SimpleXML");

    Kubwezeretsa ZOONA kapena ZABODZA.

    PS Osamamwa khofi ndekha koma nditha kuyika 'ndigule bokosi la ma donuts'

    • 2

      Pezani batani kuti mupereke, Nick! Ndiwe wopulumutsa! Choseketsa ndichakuti (kuchotsera woyendetsa), ndimakhala ndi nambala yanga yoyeserera ndikugwiritsa ntchito kuwunika koyenera. Iyenera kuti idachedwa chifukwa pomwe ndimayiyika, ndidayisokoneza!

      Ndasintha malamulo ndi positi ya blog. Funso: Ubwino uliwonse wa wina ndi mzake? Ndikulingalira kuwonjezera_kutsitsidwa ndi njira yoyera kwambiri komanso yofulumira kuthana ndi izi!

      Zikomo Nick!

  2. 4

    yum kukhazikitsa php55-xml.x86_64 kukhazikitsaXXL yosavuta ya php 5.5.11

    Kuthamanga Kwambiri
    Kuyika: php55-xml-5.5.11-1.el6.x86_64 1/1
    Kutsimikizira: php55-xml-5.5.11-1.el6.x86_64 1/1

    ndiyeno idayika
    /usr/lib64/php/modules/simplexml.so

  3. 5

Mukuganiza chiyani?

Tsambali likugwiritsa ntchito Akismet kuchepetsa spam. Phunzirani momwe deta yanu ikufotokozera.