Bu kod sonları PHP4 hakkında?

0 Cevap

Bu kod bir wordpress eklentisi parçasıdır. Sayfanın yerde 2 fonksiyonu bozulur ve bu noktada sayfanın çıktısını durdurur.

Ben Sorun tüm olasılığına PHP4 olduğunu tespit ettik. PHP4 tarafından desteklenen değil Yani eğer ben onun DOMDocument çağrısını tahmin ediyorum.

Eğer öyleyse, nasıl try / catch olmadan ve sayfayı donmadan uyumluluk ve incelikle çıkış için test edebilirsiniz?

function rseo_get_seo($check, $post){
    switch ($check)
    {
    case "h1": return rseo_doTheParse('h1', $post);
    case "h2": return rseo_doTheParse('h2', $post);
    case "h3": return rseo_doTheParse('h3', $post);
    case "img-alt": return rseo_doTheParse('img-alt', $post);
    }
}

function rseo_doTheParse($heading, $post){
//code breaks somewhere in here and freezes output of page. How can I error check this without try/catch?
    $content = $post->post_content;
    if($content=="") 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.'")])');
        }
}

0 Cevap