there is no such thing as correctly styled code...
if you can read it as your typeing then its ok code
if you can read through your code at a glance after you've finished, the its great code
if you can figure out what you were writing after going back to it months later, then its wonderful code
if my sister can read through you code and understand what its doing, then its perfect code
so my advise is.. be consistant... USE COMMENTS
PUNCHLINE: it doesn't matter what there are as long you have them
#hate this:
$name = 'dan'
$state_code = 'VA';
#like this:
$name = 'dan'
$state_code = 'VA';
rules i follow for good or ill: most people have rules for these categories
1) Common Variable Names
me:
all lowercase with _ seperating words
$i_am_a_variable = 'blah'
ive seen people specify type also:
$int_integer = 5;
$str_string = 'i am a string';
$arr_array = array( 'im an aray' );
$obj_object = array( 'im an aray' );
2) Common Function Names
me:
first letter lowercase all other words Uppercase, no spaces b/w words
function formatTheText() {}
function getFromDatabase() {}
$i_am_a_username = findUserName();
3) Common Class names
me:
all first letters Caps, no divisions
class MessagePasser
$message_passer = new MessagePasser();
4) Common Scheme for commenting
me:
i write out my comments first for the function in plain english, then fill in with code what i was talking about
so my comments tend to have a consisent style to them than i can follow afterwards