Jump to content

Best Way to Exit Code Blocks


Humpty

Recommended Posts

G'day Guys,

 

Here is a Query from a quer bloke:

(Visualising VB code structure in my head as I type this)

 

I want to create a code block, Sub, Function whatever you want to call it.

 

I want to exit that block but still permit the PHP script to run. (Example Ideal World: Use a whole bunch of Includes with the ability to use

exit();

without stopping the main script.)

 

I'm after either a push in the right direction or a recomendation on a way to do this.

 

At this stage all I can think of is to use

continue;

and place all my code in a loop which loops once.

 

If this post is a little too Dr. Seuss please let me know and I will try to reword it. Thanks - humpty

Link to comment
https://forums.phpfreaks.com/topic/67443-best-way-to-exit-code-blocks/
Share on other sites

... but if you just want to exit the funtion why not use return ?

 

That was exactly the point, I wasn't in a function to start with.  That does seem like the best way to go though. A function with no variables will just as well as a function with variables, and on the same side of the fence there is no need to return any values etc, just use return to exit that function.

 

That is what I was looking for, seems like it would be the best and closest thing to a sub.

 

Thanks dudes. (will leave topic unsolved for a bit in case someone comes up with somethign else)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.