Jump to content

Cleaning up my classes...


pthurmond

Recommended Posts

I am trying to clean up my class to be more readable. Currently each property (aka variable) is declared on separate lines.

 

Example:

class user
{
     private $item;
     private $thing;
     private $whatever;
     //etc
}

 

Is is valid to instead write it like this?:

class user
{
     private $item, $thing, $whatever;
     //etc
}

 

This is roughly what is done in C++, with some minor differences since the variable type is declared as well.

Also I want to know if PHP allows function prototypes like C++ does. This is where you declare the function in the class and the list of possible parameters and then you define the functions either in another file or directly below the class in the same file. Can this be done in PHP as well?

 

 

Thanks,

Patrick

Link to comment
https://forums.phpfreaks.com/topic/60859-cleaning-up-my-classes/
Share on other sites

his is where you declare the function in the class and the list of possible parameters and then you define the functions either in another file or directly below the class in the same file.

 

Not really what your looking for but you may want to look into abstraction or even using interfaces.

 

As for this...

 

private $item, $thing, $whatever;

 

Did you try it? Its valid.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.