Reply to Re: Fatal Error on Polymorphism

Your name:

Reply:


Posted by Erwin Moller on 03/01/07 10:03

Kesavan wrote:

> On Mar 1, 11:47 am, Michael Fesser <neti...@gmx.de> wrote:
>> .oO(Kesavan)
>>
>>
>>
>> >I need polymorphism in php.
>> >When I run this following code I get the following error.
>> >Fatal error: Cannot redeclare aClass::aPrint() in C:\Program Files
>> >\xampp\htdocs\k7\prCls.php on line 16
>>
>> >How I rectify it?
>>
>> ><?php
>>
>> > class aClass{
>>
>> > function aPrint($name){
>> > echo $name;
>> > }
>>
>> > function aPrint($name,$age){
>> > echo $name;
>> > echo $age;
>> > }
>> >[...]
>>
>> PHP doesn't support that. But you could make $age an optional argument
>> and check inside the function whether it was passed or not:
>>
>> function aPrint($name, $age = NULL) {
>> print $name;
>> print !is_null($age) ? $age : '';
>> }
>>
>> Micha
>
> Thanks Michael,
>
> Your trick help's me..,
> Isn't PHP fully OOP language/

No, it isn't: go Java or C++ or something like that if you want 'real'
method overloading.
The support PHP gives for OOP is enough to get almost all tasks done.


Regards,
Erwin Moller

>
> Kesavan M
> m.kesavan@hotmail.com

[Back to original 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

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