You are here: Re: Does PHP have an equivalent of JavaScript's prototype object? « PHP Programming Language « IT news, forums, messages
Re: Does PHP have an equivalent of JavaScript's prototype object?

Posted by Erwin Moller on 11/14/05 11:34

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?
>
> thanks!!

Hi,

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
you like.

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация