PHP programmers in here please!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ro8in
    Confirmed User
    • Sep 2006
    • 1542

    #1

    PHP programmers in here please!

    if I had a class lets say

    class myclass {
    function myfunction() {

    }
    }

    Why in the world would I do

    $myclass = new myclass

    and use the function as
    $myclass->myfunction

    while I can forget all that and just do

    myclass::myfunction()


    what can be a possible reason not to use the double colon way??

    i can't think of any...
    ------
    Offcourse its a dude posting here. Probably a fut ugly one too. Fuck still people falling for this 100 year old trick
  • woj
    <&(©¿©)&>
    • Jul 2002
    • 47882

    #2
    the point of classes isn't so you can put functions inside of them...

    the point is that you create objects, which have certain properties, and you make them do stuff by calling certain methods...
    Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
    Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
    Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

    Comment

    • ro8in
      Confirmed User
      • Sep 2006
      • 1542

      #3
      thanks for your reply

      I get it now

      using :: is just static

      while the other way I could do

      $myclass1 = new myclass("yourname")
      $myclass2 = new myclass("myname")

      then $myclass1 and $myclass2 would refer to the same class but have different properties..

      intresting stuff....

      but why php can only extend one class?
      Last edited by ro8in; 10-31-2009, 02:17 PM.
      ------
      Offcourse its a dude posting here. Probably a fut ugly one too. Fuck still people falling for this 100 year old trick

      Comment

      • redwhiteandblue
        Bollocks
        • Jun 2007
        • 2793

        #4
        Originally posted by ro8in
        intresting stuff....

        but why php can only extend one class?
        PHP doesn't support multiple inheritance if that's what you mean. But you can derive a class from another class that is derived from another class and so on.
        Interserver unmanaged AMD Ryzen servers from $73.00

        Comment

        Working...