Forum Moderators: coopster
<?php
include ('snoopy.class.php');
class ccs
{
private $_name;
private $_skey;
public function __construct()
{
global $snoopy;
$snoopy = new Snoopy;
}
public function priorityMsg()
{
if($snoopy->fetchform($priorityUrl)) {
$formelements = $snoopy->results;
}
}
What I am needing is for the $snoopy object to be available in the other functions in the class. I tried declaring it as global but when I try to use a function (fetchform) of this Snoopy object in other functions in the Ccs class, I get an error as shown:
Fatal error: Call to undefined method stdClass::fetchform() in /home/public_html/include/include_Ccs.php on line 102
So what am I doing wrong? Is it a scope problem?
class ccs
{
private $_name;
private $_skey;
private $snoopy;public function __construct()
{
$this->snoopy = new Snoopy();
}
...etc...
}
Then within the other functions, you would use
$this->snoopy instead of just $snoopy. Try that and see what happens. :)