1

I have a plugin that has a single method that requires PHP5. How can I code around the fact that the server may have PHP4?

Code is below... (I'm thinking its the DOMDocument object that's freezing the plugin when running on a PHP4 server.

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}
1
  • what exactly are you trying to do using DOMDocument? Commented Jan 14, 2011 at 21:46

3 Answers 3

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

Try phpversion();

2

What exactly is the error you're getting? To find out if a certain function is available to you or not, use function_exists(). http://us.php.net/manual/en/function.function-exists.php

Not the answer you're looking for? Browse other questions tagged or ask your own question.