Page 1 of 1

access modifier for functions in a class

Posted: Mon Mar 29, 2004 2:13 am
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

Posted: Mon Mar 29, 2004 8:47 am
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.