Fa WordPress hanno costruito in riferimento alla versione di PHP sua esecuzione in? [chiuso]

wordpress.stackexchange https://wordpress.stackexchange.com/questions/7002

  •  16-10-2019
  •  | 
  •  

Domanda

Ho un plugin che ha un unico metodo che richiede PHP5. Come posso codice intorno al fatto che il server possa avere PHP4?

Codice è al di sotto ... (sto pensando proprio l'oggetto DOMDocument che gela il plugin durante l'esecuzione su un server PHP4.

function rseo_doTheParse($heading, $post){
    $content = $post->post_content;
    if($content=="" || is_php4()) return false;
    $keyword = trim(strtolower(rseo_getKeyword($post)));
    @$dom = new DOMDocument;
    @$dom->loadHTML(strtolower($post->post_content));
    $xPath = new DOMXPath(@$dom);
    switch ($heading)
        {
        case "img-alt": return $xPath->evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])');
        default: return $xPath->evaluate('boolean(/html/body//'.$heading.'[contains(.,"'.$keyword.'")])');
        }
}


function is_php4(){//code here}
È stato utile?

Soluzione

function is_php4(){
  return version_compare(phpversion(),'5','<');
}

Altri suggerimenti

Che cosa è l'errore che stai ricevendo? Per sapere se una determinata funzione è disponibile per voi o meno, utilizzare function_exists (). http://us.php.net/manual/en/function.function -exists.php

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top