Ok, here is my dilemma. I've been a PHP writer for 5 years, have been getting paid to do it full time for almost 4. I recently missed a good opportunity because I didn't know enough OO PHP. Ok then, I say, lets learn it. So I printed out the OO PHP Part 1 tutorial, and I read a great article somewhere on the strengths and weaknesses.
It sucks that OO PHP is becoming sort of a standard. It's spliting PHP in half in terms of usage. I have to jump over to the better side and the split is the learning. If someone handed me an OO PHP class right now and said use it, I'd struggle big time. PHP is often praised for being super easy to learn.
I'm all for the learning. I've read the article twice, and I could probably spit out a good class right now.
I'm still having trouble justifing the extra work.
Within the past 2 years, I've started to develop entirely using functions. Everything I do is usually a function. I use this one a ton:
<?
function super_property($table, $id, $property){
$sql = "SELECT `$property` FROM `$table` WHERE `id` = '$id'";
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
$result = mysql_fetch_array($query);
return stripslashes($result[$property]);
}
?>
So I have a large function file that I use for most websites. In new projects I reuse a ton of them, and add in what is missing.
Now this thread is half gripe, half motivate me. In the end, I will learn OO php, and I will start to use it.
I'm just having a hard time finding the point. It's extra code. When I roll a function into a class, I have to add lots of $this-> in front of variables. Sure you can just call a class when you need it, but you can call a function list as well.
I'm sure you get a large amount of posts like this, so don't let me bother you. I think I just need encouragement either way, or some helpful tips for learning it and getting it down.
Thanks!
Clint