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? 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. 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/ 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() { ....). 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
Archived
This topic is now archived and is closed to further replies.