Stop execution of code in php

Some time during debugging code at our end through programming language we want to stop the execution of code at some desired place. In asp, Response.End() is used for this purpose and in php exit; is used for this same purpose.

Example:-

echo "Hello World";

exit;

echo "Hello Readers";

Now just first line will be executed and Hello World will be displayed, the reason why Hello Readers will not be executed and displayed is the word exit, when compiler compile this word(exit) the execution of php script will be stopped. So whenever you want to stop the execution of php code just use exit; for this purpose.

0 comments: