In several of my programming courses in the University, my teachers always told me the following:
A function and a procedure are basically the same thing: the only difference is that a function returns a value, and the procedure doesn't.
That means that this:
function sum($a, $b) {
return $a + $b;
}
... is a function, and this:
function sum($a, $b) {
echo $a + $b;
}
... is a procedure.
In the same train of thought, I've seen that a method is the equivalent of a function in the OOP world.
That means that this:
class Example {
function sum($a, $b) {
return $a + $b;
}
}
Is a method — but how do you call this?
class Example {
function sum($a, $b) {
echo $a + $b;
}
}
What's the equivalent name, or how do you call a method that doesn't returns anything?
pascal
. But really you are worrying about abstract concepts that depend on the current language for exact definition. As long as people understand what you mean it should not make a difference.Example.sum(2, 5);
. You want to know what you call it.