Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
November 14, 2005, 7:48 am
rate this thread
AFAIK you cannot easily extend the existing String in PHP.
(You would have to dive into the sourcecode, modify it, and recompile)
But you can of course create your own wrapper-object.
Just create a new class MyString and extend it to your liking with methods
No for two reasons:
1) PHP has primitive types which are not objects (strings, integers, floats,
Of course there is nothing to stop you creating a class and manipulating the
data in an instance using a function or a seperate class.
Surprise: There ain't even a string object!
PHP is all about speed through native code.
So strings are primitive types.
But for your example, as for most of the common string operations:
Do not reinvent the wheel! All common string manipulation functions are
already implemented as fast compiled C-code...