| This simply isn't possible in a way that would be convenient. For example, how would I make a string abstraction? Create a class? Ok, so we have: $str = new String("foo")
$str->replace(...) over $str = "foo"
str_replace($str, ...) This is fine, if we ignore the fact it's much slower. Where it really gets annoying is PHP's lack of operator overloading. That means to concatenate I'd need to do $str->concat($str2)->concat(new String(" "))->concat($str3) instead of $str . $str2 . " " . $str3 There's things you can do to make the API a little bit more convenient (i.e. allow it accept PHP strings, etc.), but ultimately it becomes a huge pain, especially if you want to start interoperating with other libraries that are using a different abstraction or, more likely, using the regular PHP types and functions. |