Yes that is right everyone. Go to classes now!
I've just spend the last few hours playing with Classes in php; and wow what a difference.
I've just coded myself a mysql database class. This class connects to the database plus processes queries. The processing queries section is really useful for two reasons:
1) Cuts back on code as I do not need to retype anything. If I wanted to count how many rows there are in a table the old code would look like this:
$query = "SELECT count(*) FROM news";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo $row['count'];
The new one is simply:
echo $database->numofrows("SELECT count(*) FROM news");
2) I can now change over to another database system if needed. All I do is replace my mysql class with another class. No other code change is needed.
If you're running Wordpress you're lucky enough to have programmers who know what they're doing. WP already uses classes.
So who here has found the wonders of classes?
When I started work on my incompleted CMS project, I tried classes out for while. Needless to say I didn't understand them then. Post-HSC when I revive my CMS project, i'll definately convert the current code to classes.
Only in C++/C#. Aparantly OO elements in PHP4 are kinda clunky - which is one of the things that is supposed to be much better in PHP5.