I recently had an idea to create my own String class to make using PHP’s functions easier. Instead of strlen($str) I write $str->length(). Makes it easier to remember parameter orders in certain functions, like substr.
I ran some timing scripts on it and found that it’s about 5 times slower than using the regular functions. I haven’t tested this in a real app yet, so I don’t know how negligible that will be (1ms vs 5ms or 100ms vs 500ms?).
Anyway it struck me that now PHP is now focusing more on OOP, wouldn’t it make sense for strings, arrays and other basic types to be object oriented? They could then name the functions better and code would just “feel” nicer. And slowly phase out the old way of doing things. Any pros/cons to this?
You could always document your code and just use the functions that PHP has provided. It is hard to tell whether or not it is going to affect you in the long run. There are many different factors that can influence that. Give it a shot, maybe and if it does not work out switch back to the original way.
Personally, I would just keep my document well documented instead of getting too fancy. If you want to make the push into more OOP your best bet is to look into a Framework.
I wish PHP would make it that simple from the start. The code would look so neat.