I'm self taught and have been coding for darn near 25 years, but I can't say that I've ever intentionally written a class. But since I'm playing and always trying to learn, I'd like to know what the big advantage is.
For example, this is close to the example given on php.net:
class thisClass {
function thisFunc() {
return 'bar';
}
}
$foo = new thisClass;
echo $foo->thisFunc();
What is the advantage to that as opposed to:
function thisFunc() {
return 'bar';
}
echo thisFunc();
I recognize, of course, that the example is super simple and there might not be a specific advantage in that case. But I've been reading about it all day, and the only real reason I can find to use a class is because "it makes the code clearer". It definitely doesn't seem clearer to
me, though, so is it just something that a different type of programmer would think is clearer?