mga_ka_php Posted July 22, 2010 Share Posted July 22, 2010 what is the for writing { function myfunc { or function myfunc { it should be right after myfunc or below function myfunc? Quote Link to comment https://forums.phpfreaks.com/topic/208526-right-after-or-below-function/ Share on other sites More sharing options...
dezkit Posted July 22, 2010 Share Posted July 22, 2010 the one you think looks prettier, they both work. Quote Link to comment https://forums.phpfreaks.com/topic/208526-right-after-or-below-function/#findComment-1089501 Share on other sites More sharing options...
bh Posted July 22, 2010 Share Posted July 22, 2010 Hi, http://en.wikipedia.org/wiki/Programming_style http://www.dagbladet.no/development/phpcodingstandard/ Quote Link to comment https://forums.phpfreaks.com/topic/208526-right-after-or-below-function/#findComment-1089504 Share on other sites More sharing options...
jd307 Posted July 22, 2010 Share Posted July 22, 2010 Like already stated, you can write it either way. I prefer to write code the second method you have posted: function myfunc() { .... do something .... } This is because I feel that it is neater, clearer and the fact that I am notorious for writing large functions that have IF, ELSE, WHILE, FOR, FOREACH, etc. inside and find out that my code produces errors because I didn't close one of the parentheses. Written this way, I find it very easy to find out where I didn't close the parentheses and solve my problem. I have, however, seen many scripts (possibly more than not) written using the { at the end of the line of a function (e.g. function myfunc() { ....). Quote Link to comment https://forums.phpfreaks.com/topic/208526-right-after-or-below-function/#findComment-1089553 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.