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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.