access modifier for functions in a class

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

access modifier for functions in a class

Post by davidklonski »

Hello

I am new to using writing PHP classes.
I was wondering whether PHP supports access modifier such as public, protected and private like Java and C++ do.

I would like to encapsulate some of the functions in my classes and make them private. Is it possible?

If so, could someone show me how this is done?

thanks
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

No - but that's coming in php5.

You can create conventions such as prefix all private methods with an underscore. I'll usually also separate them from the interface methods with a big comment block.
Post Reply