You are here: Re: Is there a generic Object in PHP? « PHP Programming Language « IT news, forums, messages
Re: Is there a generic Object in PHP?

Posted by Daniel Ennis on 10/12/22 12:00

KDawg44 wrote:
> On Jan 15, 9:29 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> KDawg44 wrote:
>>> Hi,
>>> I would like to have a function that takes a generic object and takes
>>> some action on this. Something like,
>>> function AMethod(Object obj) {
>>> DoSomeStufftotheObject;
>>> }
>>> then be able to pass various object types in. Is there a way to do
>>> this in PHP? Do classes automatically inherit from a generic Object
>>> like in Java?
>>> Thanks.
>> No, there is no generic object in PHP. However, you don't need to
>> specify what kind of object is being passed, i.e.
>>
>> function AMethod($obj) {
>>
>> will take anything (not just objects). And from there you can figure
>> out what was passed.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Thank you.... my brain is stuck in JAVA mode and i forgot you do not
> have to declare what is being passed in!
>
> Thanks!
you can also do if(is_object($var)) to make sure its an object.

--
Daniel Ennis
faNetworks.net - Quality Web Hosting and Ventrilo Services
System Administrator / Web Developer
PHP Developer for 6 years
daniel@fanetworks.net

 

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

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