Summary of questions about Goto in PHP

Source: Internet
Author: User
Do is a multi-conditional judgment of the small thing, in order to structure clear, easy to expand, want to use if else, each other with Goto jump into the next condition, each piece of code has been tested normal, such as the following directly in the braces to the inside of a to execute always have problems, seek advice

if () {do something;} Else{goto A;} a:{$x =1; $y = 2; Calculation statement:}

See the demo example using {}, at most only executed one sentence, I want to execute multiple sentences, including assignment and calculation
Is the curly brace only a calculation, not an assignment?

Hello, the goto operator can be used to jump to a specified location in the program. The target location can be tagged with the target name plus a colon. The Goto in PHP has a certain limit and can only jump in the same file and scope, meaning you can't jump out of a function or class method, or jump into another function. You can't jump into any loop or switch structure either. A common use is to jump out of a loop or switch, instead of a multi-layered break.

Example #1 Goto Example

<?phpgoto A;echo ' Foo '; A:echo ' Bar ';? >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.