PHP: what are the differences between goto and other control structures like while

I checked the application opcodes and noticed that the command goto

is performing the operation JMP

. However, some structures such as if

, while

and for

, also use JMP

as goto

.

Questions:
1. Why shouldn't we use goto

?
2. Was the command deprecated goto

in PHP?
3. What is the significance of the dinosaur in this picture?

enter image description here

+3


source to share


1 answer


In short, goto is simple valid code, it's a matter of taste. BUT, when dealing with multiple people, code maintainability becomes more important than personal taste. You can populate your code with goto, but then I wonder why you chose OOP in favor of clean assembly.

Q1. Why shouldn't we use goto?

A1. Difficult to follow / maintain. Try to re-read the code for several years.

Q2. Is goto command obsolete in PHP?



A2. No .

Q3. What's the point of a dinosaur in this picture?

A3. Goto is one of the most ancient control structures of all the dinosaur talks about. When you use it, it will bite you sooner rather than later.

+3


source







All Articles