Reputation: 2291
I am trying to access the function file_get_contents_curl
. from fucntion get_facebook_details()
.
class frontend {
public function file_get_contents_curl($domain) {
}
public function get_all_seo_details() {
require_once('details-functions.php');
$facebook_details = get_facebook_details($cur_domain);
}
}
details-functions.php
function get_facebook_details() {
$result = file_get_contents_curl('http://graph.facebook.com/'.$username);
//.... some more code
}
I tried:
$result = self::file_get_contents_curl('http://graph.facebook.com/'.$username);
Fatal error: Cannot access self:: when no class scope is active.
$result = $this->file_get_contents_curl('http://graph.facebook.com/'.$username);
non-object this error
$result = frontend::file_get_contents_curl('http://graph.facebook.com/'.$username);
Strict standards: Non-static method frontend::file_get_contents_curl() should not be called statically
Fatal error: Call to undefined function file_get_contents_curl()
Upvotes: 1
Views: 336
Reputation: 12039
You should write the function as static. self::
can be used to to call function statically. If you don't write the function as static then can use $this->
to call the function. Try something like this
class frontend {
public static function file_get_contents_curl($domain) {
}
public static function get_all_seo_details() {
require_once('details-functions.php');
$facebook_details = get_facebook_details($cur_domain);
}
}
Upvotes: 1
Reputation: 1580
You'll need to make those methods static if you wish to call them statically outside of the class.
public static function file_get_contents_curl(){ ... }
Upvotes: 0