0

can we call a static function in other static function in a class if yes please help me.I am using this php code.

static function getconfig()
{
$db = JFactory::getDBO();
$query='select * from #__yellowpages_config';
$db->setQuery($query);
$result=$db->loadObject();


$config->city=JRequest::getVar('city',0);
$config->country=JRequest::getVar('c',0);

if($config->city==0)

$config->city=$result->city;

if($config->country==0)

$config->country=$result->country;

return $config;

}
static function getitem()
       {
        //how I call the getconfig function here.
       }
Maneesh Mehta
  • 497
  • 3
  • 8
  • 17

2 Answers2

4

Try using self::getconfig() instead.

Sherlock
  • 7,525
  • 6
  • 38
  • 79
2

Use self::method() if you want to refer to the same class.

Use static::method() if you want to refer to whatever class in hierarchy which you call the method on.

See also this question: New self vs. new static

Community
  • 1
  • 1
ComFreek
  • 29,044
  • 18
  • 104
  • 156