It is currently Thu Sep 09, 2010 16:08
  • View your posts
  • FAQ
  • Register
  • Login

  • All times are UTC + 1 hour [ DST ]



    Post new topic Reply to topic  [ 4 posts ] 
    Author Message
     Post subject: Random static method
    PostPosted: Fri Mar 12, 2010 18:33 
    Offline
     E-mail  Profile

    Joined: Sat Jun 14, 2008 20:24
    Posts: 153
    I just found this in a mods/signature_generator/default/default.php on line 57

    Code:
    $img = imagecreatefromjpeg(Pilot::getPortraitPath(64,$pid));


    I wasn't aware that the pilot class was a static class or had any static methods. This method is not declared as static either.

    Is this a mistake? I assume it is, but why doesn't it throw up an error?

    Just curious :)

    _________________
    Fly Safe be Dangerous


    Image


    Top
     
     Post subject: Re: Random static method
    PostPosted: Fri Mar 12, 2010 19:17 
    Offline
     E-mail  Profile

    Joined: Sat Jun 14, 2008 20:24
    Posts: 1215
    Location: England
    As long as a method doesn't use $this it can be called statically. PHP doesn't really care. The getPortraitPath() method only uses $this if $id isn't set, so as long as it is set then no error will occur.


    Top
     
     Post subject: Re: Random static method
    PostPosted: Fri Mar 12, 2010 19:46 
    Offline
     E-mail  Profile

    Joined: Sat Jun 14, 2008 20:24
    Posts: 153
    mastergamer wrote:
    As long as a method doesn't use $this it can be called statically. PHP doesn't really care. The getPortraitPath() method only uses $this if $id isn't set, so as long as it is set then no error will occur.


    Thanks MG. Is there any advantage to doing this?

    _________________
    Fly Safe be Dangerous


    Image


    Top
     
     Post subject: Re: Random static method
    PostPosted: Fri Mar 12, 2010 19:50 
    Offline
     E-mail  Profile

    Joined: Sat Jun 14, 2008 20:24
    Posts: 1215
    Location: England
    Yes. It allows you to call the method statically and give it the ID, and have it return the portrait path, and you can use it on an instance of Pilot without the ID argument and it'll get the ID itself.


    Top
     
    Display posts from previous:  Sort by  
    Post new topic Reply to topic  [ 4 posts ] 

    All times are UTC + 1 hour [ DST ]


    Who is online

    Users browsing this forum: No registered users and 1 guest


    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum

    Search for:
    Jump to:  
    cron
    Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group  
    Style Designed By phpBBegypt