I have some third party classes and I want to use it inside of different function of my new class.
Below is some structure of my own class:
<?php
$curl = new curl();
class stats
{
public function foo1()
{
$foo1 = $curl->getPage($domain);
// more stuffs
}
public function foo2()
{
$foo2 = $curl->getPage($domain);
// more stuffs
}
}
?>
but it’s not working.
You don’t seem to really grasp some of the workings of OOP. Please refer to http://www.php.net/manual/en/language.oop5.basic.php for more information.
If you want to use the
curlvariable inside your class, you should have defined it either as a property of that class or inside the methods of your class. A property will most likely suit your needs: