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 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]


Удаленная работа для программистов  •  Как заработать на 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

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