gevans Posted July 3, 2009 Share Posted July 3, 2009 http://www.php.net/manual/en/control-structures.goto.php So what does everyone think of this new operator? Introduced in PHP 5.3, it's a strange direction to take. It seems to be giving you the option to ignore good coding practice, like setting variables as 'global' inside your function, or using 'or die()' as daniel0 recently wrote about in the phpfreaks blog. Even the image at the bottom of the manual page is taking the p*ss out of the new operator. Having that there is surely the PHP team admitting that it's not a best practice piece of code, but is there anywhere it could be used well? How is this any better than using the already existing if/else conditional statements? Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/ Share on other sites More sharing options...
Daniel0 Posted July 3, 2009 Share Posted July 3, 2009 Even the image at the bottom of the manual page is taking the p*ss out of the new operator. Ha... what the hell? Someone on the docs team having fun? Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868474 Share on other sites More sharing options...
.josh Posted July 3, 2009 Share Posted July 3, 2009 goto is just like the old basic style goto: You mark a certain position in your code with a label. You can then use goto to jump to that position. I don't really see what goto has to do with setting variables to global inside functions or using die? Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868476 Share on other sites More sharing options...
Daniel0 Posted July 3, 2009 Share Posted July 3, 2009 I don't really see what goto has to do with setting variables to global inside functions or using die? All of them reduces maintainability. Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868478 Share on other sites More sharing options...
.josh Posted July 3, 2009 Share Posted July 3, 2009 Well I mean yeah I can understand how it would go in the same group as those things, filed under "bad practice" (although I still stand by my argument against die being in that category 100% of the time...) but the way he said it made it sound like that goto somehow did those things. Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868480 Share on other sites More sharing options...
gevans Posted July 3, 2009 Author Share Posted July 3, 2009 It seems to be giving you the option to ignore good coding practice I think that made it very obvious that I was talking about bad coding, not comparing their functionality. but the way he said it made it sound like that goto somehow did those things. Did what things? goto sets a variable as global, or kills the script? I hardly think that's a realistic assumption, or one that could be derived from my OP Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868482 Share on other sites More sharing options...
.josh Posted July 3, 2009 Share Posted July 3, 2009 So what does everyone think of this new operator? Introduced in PHP 5.3, it's a strange direction to take. It seems to be giving you the option to ignore good coding practice, like setting variables as 'global' inside your function, or using 'or die()' as daniel0 recently wrote about in the phpfreaks blog. You start out by asking what we think of this new operator (as a side-note, I'm kind of scratching my head about why they are calling it an operator..). You then mention when it was introduced, and how it is strange. You then say that it seems to be "giving you the option to ignore good coding practice, like setting variables as 'global' inside your function, or using 'or die()'..." You clarified by saying you were giving examples of bad programming practice. But the way you said it in your OP, you are giving examples of how it is giving you the option to ignore good coding practice. That's how you wrote it. That's the grammatically correct way of reading what you wrote. So I was confused and asked about it. Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868488 Share on other sites More sharing options...
zq29 Posted July 3, 2009 Share Posted July 3, 2009 I just love the fact that they have used an XKCD comic in the manual... Brilliant. Why the devs have added goto, I have no idea. Who's ever sat there and thought "Damn, I wish I could just use a goto..."? Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868489 Share on other sites More sharing options...
.josh Posted July 3, 2009 Share Posted July 3, 2009 I just love the fact that they have used an XKCD comic in the manual... Brilliant. Why the devs have added goto, I have no idea. Who's ever sat there and thought "Damn, I wish I could just use a goto..."? A microsoft spy! A mole within the php organization! Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868491 Share on other sites More sharing options...
gevans Posted July 3, 2009 Author Share Posted July 3, 2009 That's the grammatically correct way of reading what you wrote. I'll admit, my english isn't fantastic, though I do live in the UK and it is my first language. I do however proof read my posts and still feel that it reads as I expected and intended. It seems to be giving you the option to ignore good coding practice, like setting variables as 'global' inside your function, or using 'or die()' The first thing I do is make a statement - (ignore good coding practice). Then I make comparisons to that statement. Making my two comparisons comparable to ignoring good coding practice. Reads fine? Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868494 Share on other sites More sharing options...
.josh Posted July 3, 2009 Share Posted July 3, 2009 Of course it makes sense to you; you wrote it. But anyways, my intention was not to be some kind of grammar police. I read it and interpreted it a certain way that caused me to be confused, so I asked about it. You clarified it. Let's all get jiggy wid it. Na na nana nanana. Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868550 Share on other sites More sharing options...
nrg_alpha Posted July 3, 2009 Share Posted July 3, 2009 I came across this page discussing goto, as well as this blog that gives an example of how it can be used. Personally, I can't see myself using goto ::shrugs:: Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868552 Share on other sites More sharing options...
gevans Posted July 4, 2009 Author Share Posted July 4, 2009 Na na nana nanana. I'm well up for getting jiggy 'wid it!! And I'm glad I'm not the only that doesn't see a great purpose for goto! Quote Link to comment https://forums.phpfreaks.com/topic/164687-control-structure-goto/#findComment-868642 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.