PHP: ZvakarerukaXML Yakatakurwa?

Depositphotos 11843590 s

Pane mapulagini mashoma andakavaka ayo anoda PHP5 + uye NyoreXML. SimpleXML inzira iri nyore uye iri nani yekugadzirisa mhinduro dzeXML kubva APIs. Dambudziko, zvakadaro, nderekuti ini ndaizowana pane mashoma maemail pazuva kana pavhiki kundibvunza kuti sei mushandisi asingakwanise kurodha chirongwa uye zvakakonzera zvikanganiso.

Sezviri pachena, zviziviso zvangu pamapulagi uye pamapeji eprojekiti zvaive zvisina kukwana, saka ndakaita chinhu chakakodzera uye ndikawedzera mashandiro kumapulagi ese maviri kuti ndione kuwedzera kweXXXLL kwakatakurwa.

PHP Basa rekutarisa iyo SimpleXML yekuwedzera yakatakurwa:

basa isSimpleXMLLoaded () {$ array = array (); $ rondedzero = tora_kuregedza_zvinyorwa (); $ mhedzisiro = manyepo; foreach ($ array as $ i => $ value) {if (strtolower ($ value) == "simplexml") {$ result = true; }} dzosera mhedzisiro; }

Zvino, mukati memabasa anoshandisa SimpleXML, ini ndinogona kungoona kuti yakatakurwa ndisati ndamboedza iyo SimpleXML kufona. Kana

kana (! isSimpleXMLLoaded ()) {echo "Gamuchira saiti yako kumwe kunhu!"; dzoka; }

Ndoziva ini ndine PHP gurus iyo inocherekedza bhurogu yangu, ndiudzeiwo maitiro andakaita! Ndaburitsa zvidiki zvidiki kune ese maPulagi kuti ushandise iyi nzira.

6 Comments

  1. 1

    Mhoro Doug,

    Ndakaona imwe bug iyo inogona kunge isingamutsi kukanganisa.

    kana ($ kukosha = “SimpleXML”) {$ result = chokwadi; }

    kunge

    kana ($ kukosha == “SimpleXML”) {$ result = chokwadi; }

    Kunyangwe nekuda kwekuchengetedza. Ndinoda.

    kana (strtolower($ value) == “simplexml”) {$result = chokwadi; }

    Iwe unogona zvakare kushandisa 'extension_loaded' iyo inotora zita rekuwedzera kutarisa (case sensitive).

    $loaded = extension_loaded("SimpleXML");

    Inodzosa TRUE kana FALSE.

    PS Usanwe kofi ini pachangu asi ini ndinogona kuisa bhatani rekuti 'nditengere bhokisi remadonuts' 🙂

    • 2

      Simudza bhatani redhonati kumusoro, Nick! Uri muponesi! Chinosekesa ndechekuti (minus the strtolower), ini ndakatove nekodhi yangu yemuenzaniso ichimhanya uye ndichishandisa ongororo chaiyo. Kunenge kwadoka nekuti pandakazoipinza ndakaikanganisa!

      Ndagadzirisa kodhi uye blog post. Mubvunzo: Pane mukana weimwe pane imwe? Ini ndinofungidzira iyo extension_loaded inzira yakachena uye inokurumidza kubata neizvi!

      Ndatenda Nick!

  2. 4

    yum install php55-xml.x86_64 kuisa simpleXML yephp 5.5.11

    Running Transaction
    Kuisa : php55-xml-5.5.11-1.el6.x86_64 1/1
    Kuongorora: php55-xml-5.5.11-1.el6.x86_64 1/1

    ndokubva yaiswa
    /usr/lib64/php/modules/simplexml.so

  3. 5

Unofungei?

Nzvimbo iyi inoshandisa Akismet kuderedza spam. Dzidza kuti sei deta yako inoshandiswa.