|
Posted by Colin McKinnon on 11/14/05 22:15
alee.indy@gmail.com wrote:
> Basically, I want to add default methods to the PHP string object so
> that I can do something like:
>
> $stringvar = "hello";
>
> $stringvar -> append(" world"); // where append is some kind of
> prototyped function i define
>
> echo $stringvar; // "hello world"
>
> is this at all possible?
>
No for two reasons:
1) PHP has primitive types which are not objects (strings, integers, floats,
arrays).
2) Unlike javascript, a PHP class cannot be modified at runtime.
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.
C.
Navigation:
[Reply to this message]
|