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;
    $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}

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
function is_php4(){
  return version_compare(phpversion(),'5','<');

Try phpversion();


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.