2levelsabove Posted June 3, 2009 Share Posted June 3, 2009 I keep getting an error The second argument, 'isoutgoing', should be a valid callback I know how callbacks work in procedural but how do I call it in OOP please help function get_outgoing_links($uri){ $uri = trim(eregi_replace('http://', '', $uri)); $uri = trim(eregi_replace('http', '', $uri)); $uri = trim(eregi_replace('www.', '', $uri)); $this->url=$uri; $alllinks=explode(" ",$this->get_all_links($uri)); $outgoinglinksarray=array_filter($alllinks,"isoutgoing"); return $outgoinglinksarray; } //the call back function function isoutgoing($link) { $link1 = parse_url($link); $cleanlink1=$link1['host']; $$cleanlink1 = trim(eregi_replace('http://', '', $cleanlink1)); $cleanlink1 = trim(eregi_replace('http', '', $cleanlink1)); $cleanlink1 = trim(eregi_replace('www.', '', $cleanlink1)); if ( !strpos($link1['host'], $this->$url)) { return 1; } } Link to comment https://forums.phpfreaks.com/topic/160738-callback-functions-in-oop/ Share on other sites More sharing options...
Ken2k7 Posted June 3, 2009 Share Posted June 3, 2009 $outgoinglinksarray=array_filter($alllinks,array($this, "isoutgoing")); You mean like that? Link to comment https://forums.phpfreaks.com/topic/160738-callback-functions-in-oop/#findComment-848314 Share on other sites More sharing options...
2levelsabove Posted June 3, 2009 Author Share Posted June 3, 2009 <b>Fatal error</b>: Using $this when not in object context on line <b>396</b><br /> Link to comment https://forums.phpfreaks.com/topic/160738-callback-functions-in-oop/#findComment-848322 Share on other sites More sharing options...
roopurt18 Posted June 3, 2009 Share Posted June 3, 2009 Post all of your code and identify which is line 396. Link to comment https://forums.phpfreaks.com/topic/160738-callback-functions-in-oop/#findComment-848328 Share on other sites More sharing options...
2levelsabove Posted June 3, 2009 Author Share Posted June 3, 2009 $outgoinglinksarray=array_filter($alllinks,array($this, "isoutgoing")); ill post all code in just a few Link to comment https://forums.phpfreaks.com/topic/160738-callback-functions-in-oop/#findComment-848329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.