Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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}
share|improve this question

closed as off topic by Rarst Aug 19 '12 at 16:41

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
what exactly are you trying to do using DOMDocument? –  onetrickpony Jan 14 '11 at 21:46

3 Answers 3

up vote 7 down vote accepted
function is_php4(){
  return version_compare(phpversion(),'5','<');
}
share|improve this answer

Try phpversion();

share|improve this answer

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

share|improve this answer

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