You are here: Re: Are there static functions in PHP? « PHP Programming Language « IT news, forums, messages
Re: Are there static functions in PHP?

Posted by Jerry Stuckle on 10/03/49 11:26

Mladen Gogala wrote:
> On Sat, 10 Sep 2005 20:25:55 -0500, Jerry Stuckle wrote:
>
>
>>Mladen,
>>
>>No, private methods are different. C doesn't have classes, so it can't
>>have class members.
>
>
> Jerry, of course C doesn't have classes. C isn't an OO language while PHP
> is. Also, strictly speaking, there is no linking of PHP scripts, so the
> notion of a symbol local for an object file is not easy to translate to
> PHP. The best thing to do, if he wants to hide functions from the outside
> world, is to use private methods. Yes, that implies classes. PHP and
> C are different to that extent that you can't really compare them feature
> by feature so we have to think outside the box and come up with the best
> functional match. And that is a private method.
>

Mladen,

But if you're going to use classes, you don't need to use private methods.

The problem he's trying to solve is namespace collision. He has two
different functions with the same name and occasionally he needs to
include both in a third file. In C this isn't a problem because you can
use static functions.

In PHP you don't need to use private methods - and may not want to use
them, since they can't be called from outside the class. Just having a
method as a member of the class is sufficient to resolve the namespace
collision. And it can still be called by non-members.

Of course, this really isn't different than having different function
names in the first place - which may still be the easiest way to go.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.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

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