Click to See Complete Forum and Search --> : break


bunny1
03-22-2007, 12:43 PM
is there a method to break the code at a certain place?

PlainSense
03-22-2007, 12:48 PM
I see we have another flash commercial with a road map for "Windows Vista". How lovely and clever.

Maybe something like mysql_close();

jasonahoule
03-22-2007, 12:56 PM
If you are talking about breaking out of a loop then use

break;

polorboy
03-22-2007, 03:09 PM
There are a few ways to break out of php code at a certain spot. You can use:

die("Insert message here");
exit();

I don't know where that mysql_close() came from though, the question wasn't about closing a mysql database connection, it was about stopping any php code at any point.

PlainSense
03-22-2007, 03:15 PM
Actually, it was about breaking the code. What better way to break a code than to close it. You can always start it again.

aj_nsc
03-22-2007, 06:54 PM
I'm interested, PlainSense, how does closing a mysql connection break php code?

If you're in a loop use

break;


Other than that, you can use, as suggested die(); but I would not use exit; necessarily though because if you have any other includes, or php code that needs to be executed on a page after this, then the exit; command will stop all other php code from running, not necessarily what you want.

NightShift58
03-22-2007, 09:54 PM
Other than that, you can use, as suggested die(); but I would not use exit; exit() or die() - same-same, no difference.

http://www.php.net/manual/en/function.die.php

polorboy
03-23-2007, 08:04 AM
PlainSense, there is a huge difference between closing a connection to a mysql database and trying to break out of a code loop, or just stopping code from running. You could put in mysql_close() after every line of code in your php and it wouldn't do anything except close a connection to a mysql database (if you even had one open) and the rest of the code would keep on going.