Call a function on an object?!


Can someone tell me how can I do this?

public function __construct(){ $this->curlObj = new Curl(); } public static function curlSite($url){ self::curlObj->setOpt(CURLOPT_ENCODING , 'UTF-8'); self::curlObj->setOpt(CURLOPT_HEADER , true); self::curlObj->setOpt(CURLOPT_FOLLOWLOCATION , true); self::curlObj->setOpt(CURLOPT_RETURNTRANSFER , true); self::curlObj->setOpt(CURLOPT_BINARYTRANSFER , true); self::curlObj->setOpt(CURLOPT_CONNECTTIMEOUT , 5); self::curlObj->get($url); self::curlObj->close(); }

PHP Parse error: syntax error, unexpected ‘->’ (T_OBJECT_OPERATOR)


I think outside the class you’ll do something like

$curl=new Curl(); and then from there you can call the functions.

In the construct you don’t need to initiate the new Curl() since when you call it outside the function you already create an instance of it.

Take my words with a grain of salt since I’m learning.

Actually the curl is in another class, the above problem in another, i need to see an example.

self::curlObj should be $this->curlObj

Thanks …

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.