What is a difference between a method and a function?

Method is actually a function used in the context of a class/object.

When you create a function outside of a class/object, you can call it a function but when you create a function inside a class, you can call it a method.

class foo {
   public function bar() { // a method
     ........
   }
}

function bar() {  // a function not part of an object
}

So an object can have methods (functions) and properties (variables).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)