ungaro Posted February 13, 2007 Share Posted February 13, 2007 I have developed a website using php 4. I'm using right now php 5.1.6, and the above code gives me error: Fatal error: Call to undefined function simplexml2ISOarray() in artist.php on line 220 and that line is: $r[$key] = simplexml2ISOarray($value,$attribsAsElements); i think there is some recursion problem with this code, but i didn't understand why it fails to execute. Your helps much appreciated, Thanks... Alp function simplexml2ISOarray($xml,$attribsAsElements=0) { if (get_class($xml) == 'SimpleXMLElement') { $attributes = $xml->attributes(); foreach($attributes as $k=>$v) { if ($v) $a[$k] = (string) $v; } $x = $xml; $xml = get_object_vars($xml); } if (is_array($xml)) { if (count($xml) == 0) return (string) $x; // for CDATA foreach($xml as $key=>$value) { $r[$key] = simplexml2ISOarray($value,$attribsAsElements); if (!is_array($r[$key])) $r[$key] = utf8_decode($r[$key]); } if (isset($a)) { if($attribsAsElements) { $r = array_merge($a,$r); } else { $r['@'] = $a; // Attributes } } return $r; } return (string) $xml; } Quote Link to comment https://forums.phpfreaks.com/topic/38287-solved-converting-from-php4-to-php5-error-in-recursive-function-code/ Share on other sites More sharing options...
trq Posted February 13, 2007 Share Posted February 13, 2007 Call to undefined function means it cannot find the function definition. Are you including this function from another file? Quote Link to comment https://forums.phpfreaks.com/topic/38287-solved-converting-from-php4-to-php5-error-in-recursive-function-code/#findComment-183495 Share on other sites More sharing options...
ungaro Posted February 13, 2007 Author Share Posted February 13, 2007 no the same code is working perfectly on a php 4 setup. it fails when it tries to execute itself. it's a recursive function.... i think maybe in php 5 there are some other ways for a function to call itself?? not just name; self, this or whatever, but i couldn't find it. Quote Link to comment https://forums.phpfreaks.com/topic/38287-solved-converting-from-php4-to-php5-error-in-recursive-function-code/#findComment-183499 Share on other sites More sharing options...
ungaro Posted February 13, 2007 Author Share Posted February 13, 2007 wow, i've found the solution. i've changed the function name and all the function calls to simplexml2isoarray (all lowercase). and it seems to have solved the problem. i swear i did nothing else. strange problem. Quote Link to comment https://forums.phpfreaks.com/topic/38287-solved-converting-from-php4-to-php5-error-in-recursive-function-code/#findComment-183519 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.