Jump to content

Class Format Standards


The Little Guy

Recommended Posts

I tend to do camel case for normal terms that contain multiple words, then underscores for some kind of relation - often (but not always) to another variable, and generally protected or private.

public  $dirSeparator = null;
private $dirSeparator_windows = "\\";
private $dirSeparator_unix = "/";

public function parseXmlFeed() {

private function parseXmlFeed_channel($channel) {

private function parseXmlFeed_item($item) {

Link to comment
Share on other sites

I use camel case as well.  I'm not a fan of underscores in general.  Looks ugly, IMO, and requires extra key presses.  The exception is as a prefix to private members.  I'm torn on using them, so I often simply leave the first letter of my private members lowercase:

 

private function somePrivateFunction(){}

 

I capitalize public members, like so:

 

public function SomePublicFunction(){}

 

Class names themselves always have capitalized first letters.  Interfaces have the 'I' prefix:

 

class Example implements ISomeInterface{}

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.