goto line command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Banx
    New Member
    • Aug 2005
    • 3

    #1

    goto line command

    Help me plz..
    i'm new with this stuff
    i want to know what is php command for goto other line
    for example i want to go to line 50 and skip the previous
    can anyone help me :p
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2433

    #2
    I don't think there is an goto line command for php.

    Through a while, do-while or switch statement you can use the break function. You will have to redesign your code a little to use it.

    more information here
    niheel @ bytes

    Comment

    • Banx
      New Member
      • Aug 2005
      • 3

      #3
      Thanx

      Hi..KUB365
      thanks for the quick replay
      that's usefull...... :D

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Goto is coming, but with some restrictions.

        In PHP 6, you'll be able to create a static label and then use a break statement to jump to it:

        [code=php]
        <?php
        for ($i = 0; $i < 9; ++$i)
        {
        if (true) {
        break blah;
        }
        echo "not shown";
        blah:
        echo "iteration $i\n";
        }
        ?>[/code]

        As a general rule, just like the traditional break, you can jump *out* of loop constructs, but you cannot jump *into* them. It is unclear for the moment whether this functionality will be available outside of a loop, but given that this is an expansion of the break keyword, I would tend to assume that this functionality would only be available inside of a loop (I wonder about switches, though....).

        For more information, see this page.

        Comment

        Working...