php OOP function declarations

Posted by kris on Stack Overflow See other posts from Stack Overflow or by kris
Published on 2010-05-30T17:31:51Z Indexed on 2010/05/30 17:42 UTC
Read the original article Hit count: 268

Filed under:
|
|

I'm a big fan of OOP in php, but i feel like defining class methods gets disorganized so fast. I have a pretty good background in OOP in C++, and i am pretty comfortable with how it is handled there, and am curious if there are ways to do it similarly in php.

To be more specific, here is what i mean. I like how in C++ you can define a class header (myclass.h) and then define the actual details of the functions in the implementation file (myclass.cc). Ive found that this can easily be replicated using interfaces in php, but i havent found a good solution for the following:

I like to organize my code in C++ in different files based on how they are accessed, so for example, public methods that can be called outside of the class would be in 1 place, and private methods would be organized somewhere else - this is personal preference.

Ive tried to define class methods in php like:

private function MyPHPClass::myFunction(){ }

when the definition isnt directly inside the class block( { } ), but i havent had any success doing this.

Ive been through all of the pages on php.net, but couldnt find anything like this. Im assuming that there is no support for something like this, but thought i would ask anyway.

thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about oop