I checked the opcodes of an application and noticed that the goto
command performs the JMP
operation. However, some structures such as if
, while
, and for
also use the JMP
like goto
.
The questions are:
1. Why shouldn’t we use goto
?
2. Has the goto
command been deprecated in PHP?
3. what's the meaning of Dinosaur in this picture?
In short, goto is plain valid code, it's a matter of taste. BUT, when working with multiple people, code maintainability becomes more important than personal taste. You could fill your code with goto's, but then I'm wondering why you chose an OOP language in favour of pure assembly.
Q1. Why shouldn’t we use goto?
A1. Hard to follow / maintain. Try re-reading your code in a few years.
Q2. Has the goto command been deprecated in PHP?
A2. No.
Q3. what's the meaning of Dinosaur in this picture?
A3. Goto is one of the most ancient control structures of all, which is what the dinosaur is referring to. When you use it, it'll bite you rather sooner than later.