PHP: Puas yog SimpleXML Loaded?

Depositphotos 11843590 s

Muaj ob peb plugins uas kuv tau tsim uas yuav tsum muaj PHP5 + thiab Yooj yimXMLCov. SimpleXML yog qhov yooj yim dua thiab ua tau zoo ntawm txoj kev parsing XML cov lus teb los ntawm APIs. Qhov teeb meem, tab sis, yog tias kuv yuav tau txais ob peb email hauv ib hnub lossis ib lub lim tiam nug kuv yog vim li cas tus neeg siv tsis tuaj yeem thauj cov program thiab nws ua rau muaj qhov tsis yog.

Thaj, kuv cov ntawv ceeb toom rau ntawm cov plugins thiab ntawm cov phiaj xwm nplooj ntawv tsis txaus, yog li kuv tau ua qhov yog thiab ntxiv kev ua haujlwm rau ob lub plugins kom paub tseeb qhov SimpleXML txuas ntxiv.

PHP Function los xyuas qhov SimpleXML txuas ntxiv yog thauj:

kev ua haujlwm yogSimpleXMLLoaded () {$ array = array (); $ array = tau_loaded_extensions (); $ tshwm sim = tsis tseeb; foreach ($ array li $ i => $ tus nqi) {yog (strtolower ($ tus nqi) == "simplexml") {$ result = tseeb; }} xa $ tshwm sim; }

Tam sim no, nyob rau hauv cov haujlwm uas siv SimpleXML, Kuv tuaj yeem cia nws ua kom nrawm ua ntej Kuv sim sim hu lub SimpleXML. Yog

yog (! isSimpleXMLLoaded ()) {ncha "Qhuas koj lub xaib rau lwm qhov!"; rov qab los; }

Kuv paub tias kuv tau txais qee tus gurus PHP uas khaws qhov muag ntawm kuv qhov blog, qhia rau kuv paub li cas kuv tau ua! Kuv twb tso cov kev hloov kho me rau ob qho tag nrho Plugins siv cov qauv no.

6 Comments

  1. 1

    Kuv tuaj los Doug,

    Kuv puas tau paub tias muaj kab laum uas tej zaum tsis sau yuam kev.

    yog ($ nqi = “SimpleXML”) {$ result = tseeb; }

    yuav tsum

    yog ($ nqi == “SimpleXML”) {$ result = tseeb; }

    Txawm hais tias rau kev nyab xeeb sake. Kuv xum.

    yog (strtolower ($ tus nqi) == “simplexml”) {$ result = tseeb; }

    Koj kuj tseem tuaj yeem siv 'extension_loaded' uas siv lub npe ncua txuas ntxiv los kuaj (teeb meem rhiab).

    $ loaded = extension_loaded (“SimpleXML”);

    Rov qab los QHOV TSEEB los sis qhov tseeb.

    PS Tsis txhob haus kas fes rau kuv tus kheej tab sis kuv tuaj yeem tso ib lub thawv 'ua rau kuv ib lub thawv donuts' khawm

    • 2

      Tau txais ntawd donut khawm li, Nick! Koj yog ib tug lifeaver! Qhov dab tsi lom zem heev yog tias (rho tawm strtolower), Kuv tau ua kuv tus qauv code khiav thiab siv txoj cai ntsuas. Nws yuav tsum tau lig vim tias los ntawm lub sijhawm kuv tso nws rau hauv, Kuv messed nws!

      Kuv twb hloov kho tus code thiab ntawv blog lawm. Lus Nug: Ib qho txiaj ntsig ntawm ib qho dhau ib? Kuv kwv yees the extension_loaded yog ib tug ntau huv thiab sai txoj kev nrog no!

      Ua tsaug Nick!

  2. 4

    yum nruab php55-xml.x86_64 rau nruab yooj yim xML rau php 5.5.11

    Khiav Kev Tshaj Tawm
    Installing : php55-xml-5.5.11-1.el6.x86_64 1/1
    Verifying : php55-xml-5.5.11-1.el6.x86_64 1/1

    thiab ces nws nruab
    /usr/lib64/php/modules/simplexml.so

  3. 5

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.