drtanz Posted January 28, 2010 Share Posted January 28, 2010 I am trying to decide on using a naming convention for my functions, I've read that zend recommends camelCase but I've also come across alot of PHP functions named like so: function my_function($args) { } Which is best? Link to comment https://forums.phpfreaks.com/topic/190085-whats-the-best-naming-convention-for-functions/ Share on other sites More sharing options...
salathe Posted January 28, 2010 Share Posted January 28, 2010 Any, so long as it is clear (like camelCase and under_scored), descriptive and consistent throughout your code. Link to comment https://forums.phpfreaks.com/topic/190085-whats-the-best-naming-convention-for-functions/#findComment-1002931 Share on other sites More sharing options...
gwolgamott Posted January 28, 2010 Share Posted January 28, 2010 As salathe said as long as it is clear. Depends on your audience too. I prefer underscores, just because I can pick them out quickly is all though. Then again I tend to try to make it look cleaner at times with using underscores for variables and then camelCode for my functions, especially if intended for someone else to look at my code just to make it easier to read. Link to comment https://forums.phpfreaks.com/topic/190085-whats-the-best-naming-convention-for-functions/#findComment-1003037 Share on other sites More sharing options...
oni-kun Posted January 28, 2010 Share Posted January 28, 2010 CheckInput() CheckVars() CheckCheck() Just gets old to me. Underscores are great for pseudo-catagorization check_input_length() check_input_parameters() session_set() session_remove() display_integer() dispay_formatted() Link to comment https://forums.phpfreaks.com/topic/190085-whats-the-best-naming-convention-for-functions/#findComment-1003039 Share on other sites More sharing options...
drtanz Posted January 28, 2010 Author Share Posted January 28, 2010 Ared dashes used regularly too or are underscores preferred? Link to comment https://forums.phpfreaks.com/topic/190085-whats-the-best-naming-convention-for-functions/#findComment-1003045 Share on other sites More sharing options...
Adam Posted January 28, 2010 Share Posted January 28, 2010 Dashes are invalid characters in function/variable names. Link to comment https://forums.phpfreaks.com/topic/190085-whats-the-best-naming-convention-for-functions/#findComment-1003052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.