Calling a static function from the same class

Discussion in 'PHP' started by jestep, May 8, 2007.

  1. #1
    I'm not sure the best way to do this. Just looking for the right way to go about doing this. I just need to call a static method from a normal method within the same class.

    Example:
    
    
    class someStupidClass {
    
    function thisOne (){
    
    //do stuff
    
    //call static function
    
    return $this->output;
    
    }
    
    public static function getInfo(){
    
    //some database stuff
    
    return $info;
    
    }
    
    }
    
    PHP:
    Woould I call it the same as I would from outside the class?

    Ex: $this->info = someStupidClass::getInfo();
     
    jestep, May 8, 2007 IP
  2. xooMan

    xooMan Peon

    Messages:
    92
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, this is a typical way of calling static methods:
    ClassName::MethodName()
     
    xooMan, May 11, 2007 IP
  3. SecondV

    SecondV Active Member

    Messages:
    76
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    70
    #3
    
    self::getInfo();
    
    PHP:
     
    SecondV, May 11, 2007 IP
    jestep likes this.