The goto operation is derived directly from ASM or any other assembly language.
Here's the link: http://be2.php.net/manual/en/control-structures.goto.php
I am wondering: what can this do to make my code more organized? How can I realize this in large projects without screwing it. Since goto allows you to jump back and forth, random assignments and endless loops are waiting if you use it incorrectly.
Can someone give me an example of a good use of this?
EDIT: OK, I saw some answers and there seems to be wide consensus on using the goto statement, and that is bad.
So I'm still wondering why PHP wants to add it to the language. If they had not seen anything, they would not have done it ... so why?
Also: https://stackoverflow.com>
EDIT2: Seeing that this question caused a lot of bad things that were sad about the goto statement, I went and asked my father. He is 52 years old and is an industrial engineer.
He told me a couple of times that he was doing good programming in his day and mostly in FORTRAN and COBOL. He is currently involved in IT services, server and network agency, etc.
In any case, he said something about "back in time ..."
After discussing this a bit, he returned to the statement of goto, saying that even at one time as a student, they all knew that it was not a smart idea to use it, but then they were not much better. It was still many years to try / catch, and error handling was practically not implemented.
So what did you do to test your program? Add a few lines at the end that allow you to print the output and all you need to check the code, and then you put the line: "goto printing" or something like that to start printing your data.
And so you gradually debug your code.
He agrees that using goto in the modern programming world is pretty useless. The only thing that he considers justified is the "emergency break", which will be used in extreme debugging and unforeseen situations. For example, goto fatal_error; and the "fatal_error" part of your code does some things to show you in-depth results. But only during the creation of something. The final product should not have operator operators.
LAST EDIT: Another discussion about "goto" in PHP5.3 / PHP6