1. Computing

Discuss in my forum

Skipping over chunks of code in PHP using Goto

By , About.com Guide

You can skip over chunks of code in PHP using goto. This is not a function so it does not require parenthesis, and it only works if you have php 5.3 or later. In our example below we will echo a line, but it will not output anything if we execute the PHP, because it is in the section of code we are skipping.

<?php
goto a;
echo 'This will be skipped';

a:
echo 'Why hello!';
?>

If you run this code you will only see "Why hello!" and not the other line we echo because it is in the section of code that we skipped between goto and the mark we were searching for.

See More About
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Learn PHP
  5. How to Skip PHP Code

©2013 About.com. All rights reserved.