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?