80 likes | 272 Views
Goto statement is only available in latest version of PHP and its PHP 5.3 or higher PHP versions.
E N D
Go to Statement in PHP Prepared By www.CreativeDev.in
Go To in PHP • Goto statement is only available in latest version of PHP and its PHP 5.3 or higher PHP versions.We can say Goto statement is used to jump to other section of the program. • The Goto Statement requires a label to identify the place where the branch to be made. A label is any valid variable name and must be followed by colon(:). A label is immediately placed before the statement where the control is to be transferred.
Some Important Notes • The label: can be in anywhere in the program before or after the gotolabel; statement. • goto is not a function. Its just a statement. • When program run and get the statement like go to first; the flow of program will jump to the statement first: .This occurs unconditionally.
Example echo "Lets start with Go To"."<br />"; goto read; echo "Skip the code with Goto jump"; read: echo "Execute the code with Goto jump";
OutPUT Lets start with Go To Execute the code with Gotojump
Last but not least • In the previous example, when the code encounters the goto statement, the control transfer to the label “read”. • "Dont go to GO TO statement".Try to avoid the use of goto as far as possible but there is nothing wrong if we use it to improve execution speed of program.
Thank You Feel free to add your comments/queries on http://www.creativedev.in/2011/11/goto-statement-in-php/ For more articles, visit: www.creativedev.in