What is the difference between a method and a function? Is it that a method returns a value and a function doesn't?
See Question&Answers more detail:osWhat is the difference between a method and a function? Is it that a method returns a value and a function doesn't?
See Question&Answers more detail:osMethod 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).