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