PHP goto Statement
In this article, we will see what is php goto statement.
PHP goto statement
It transfers the control to the specified label. A text followed by a (:) symbol indicates a label.
Ex; beginning:, end:, etc.
<?php goto fullName: firstName: echo "John"; goto end; lastName: echo "Wesely"; goto end; fullName: echo "John Wesely"; end: ?> /* Output: John Wesely */
- In the above code, we use the “goto” keyword then we call the label “fullName”.
- We have created three labels namely “firstName”, “lastName”, and “fullName”. “goto end” keyword should be placed after creating each label.
- After creating all the labels, we use the “end” keyword for ending the labels.