niche Posted July 14, 2012 Share Posted July 14, 2012 What's the advantage of coding this way: $headers = "From: \"Niche\" <somebody@example.com>\r\n" .$headers .= "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"$bound_text\""; instead of this way?: $headers = "From: \"Niche\" <somebody@example.com>\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"$bound_text\""; Could it just be preference? Link to comment Share on other sites More sharing options...
Guest So Called Posted July 14, 2012 Share Posted July 14, 2012 No difference except your own ideal of readability. (Your first example has a syntax error. I'm sure you meant to terminate the first line with a semicolon. IMO too many programmers spend too little time on the subject of readability, which code if easier to read is easier to maintain. Big clue: If any of you programmers are not using tabs or tabulated code listings then you have missed an essential part of programming for ease of maintenance, and for ease of understanding your own code for debug purposes. Neat code or so called "pretty" code is easier to maintain, easier to debug. But it's difficult to define, just like beauty is difficult to define but you know it when you see it.. Link to comment Share on other sites More sharing options...
niche Posted July 14, 2012 Author Share Posted July 14, 2012 Good points. Thanks again So Called. Link to comment Share on other sites More sharing options...
birbal Posted July 14, 2012 Share Posted July 14, 2012 Beauty is no more difficult yet to define. Link to comment Share on other sites More sharing options...
Don E Posted July 14, 2012 Share Posted July 14, 2012 One thing I see that is recommended for the 'if' statement is like the following: if () { } ..whereas I prefer to write them like this: if(){ } I guess you say I like having my braces aligned. Link to comment Share on other sites More sharing options...
Guest So Called Posted July 14, 2012 Share Posted July 14, 2012 There's two different schools on that (bracket placement), as your examples show. There is no absolutely correct way, and there is no objective way to say one is better than the other. All that can be said is to stick with either one or the other throughout your entire project. I prefer this way: if (condition { // code} else { // more code} Code is more readable and easier to debug and maintain if it has a uniform style throughout. IMO code with no tabs is a PITA to work with. Link to comment Share on other sites More sharing options...
Ingolme Posted July 15, 2012 Share Posted July 15, 2012 I prefer a series of spaces than tabs. You never know how large a tab will be in different editors. Link to comment Share on other sites More sharing options...
Guest So Called Posted July 15, 2012 Share Posted July 15, 2012 Yes, I meant horizontal tabulation in some/any form, whether 2, 4 or 8 spaces, tabs, etc. Myself I prefer tabs first, or any standard second, but what's really worst is mixed standards or no horizontal tabs/spaces at all. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted July 15, 2012 Share Posted July 15, 2012 There's two different schools on that (bracket placement), as your examples show. There is no absolutely correct way, and there is no objective way to say one is better than the other. All that can be said is to stick with either one or the other throughout your entire project. I prefer this way:if (condition { // code} else { // more code} Code is more readable and easier to debug and maintain if it has a uniform style throughout. IMO code with no tabs is a PITA to work with. wouldnt this code you place above give you an error? you forgot to close up, and i perfer to code like this:if(){}else{} its more readible to me, and i tent to follow along better whiles codes like this if($this->$peter){$this->row} i tends to go off track when reading those like that, even tho i know what its saying Link to comment Share on other sites More sharing options...
Guest So Called Posted July 15, 2012 Share Posted July 15, 2012 typo, left out right parenthesis Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now