stop executing script...

  • 18 years ago

    ---some code---
    if ($bla != "bla")
      echo "something";
      //and how to make the script to go to last line, not die(), brake doesn't work too, and not to execute nothing after this line ???
    ---some more code---

  • 18 years ago

    just to get this straight, you want to continue executing code, but from further down the page?


    try using { and } to start and end the IF statements otherwise you can only have one line of code after the If statement,

  • 18 years ago

    you could try


    exit;


    (i think that's it, anyway...)

  • 18 years ago

    exit would stop all code after it from working.
    i think in order for break to work, it must but within {}'s (curley brackets).
    i have just tried this, and found that you can use {} to mark any code (without a control structure) and use break to exit it if required.  for example:


    Code:

     {
       echo "start, "
       $retval = true;
       if ($ret
    val)
           break;  
       echo "i never get printed, ";
     }
     echo "end";


    this will produce "start, end" as it will always break out of the {}'s at the iff statement.
    you can also have the {}'s nested several times, and use break 2; (or another number) to break out of the specified number of {}'s.


    I probably haven't explained it very well, but you should be able to play around and get it working.

  • 18 years ago

    look:


    some code here
    some code here


    if (id == 1) {
     some code here
     some code here
     //maybe  gogo END, and how to do that.. ???
    } else {
     some code here
     some code here
    }


    // and the code at the bottom should not be executed....
    some code here
    some code here
    some code here

  • 18 years ago

    did you try the


    exit;


    or


    return;


    statement???

  • 18 years ago

    ay, exit shoud be the one.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan