sarthak Posted March 30, 2008 Share Posted March 30, 2008 hi guys, I want to exit from a php file under some conditions like: if ($reviewNumber>=1 ) { echo "you have already reviewed this article"; exit 0; } <after this some php code>, What I want is it should exit the whole function if the code enters the if loop. But putting exit 0 is giving me an error :syntax error, unexpected T_LNUMBER . Any solution Also 1 thing i cannot work with a return statement as the calling environment is AJAX and have to send the msg by echo only. Pls help Link to comment https://forums.phpfreaks.com/topic/98592-exit-from-php/ Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 <?php if ($reviewNumber>=1 ) { echo "you have already reviewed this article"; // use exit; or die; i would'nt.. }else{ echo "what ever"; } ?> Link to comment https://forums.phpfreaks.com/topic/98592-exit-from-php/#findComment-504583 Share on other sites More sharing options...
sarthak Posted March 30, 2008 Author Share Posted March 30, 2008 ya but I want to stop the execution of the next parts of the code. which if i put in side else will be very complex. Bcoz there are further similar checkings also done below and the number of such checking is around 15. Isnt there any alternative to a return statement. Which when encountered once will return the value and stop execution of further code? Link to comment https://forums.phpfreaks.com/topic/98592-exit-from-php/#findComment-504585 Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 use the if only then........ if ($reviewNumber>=1 ) { echo "you have already reviewed this article"; // use exit; or die; i would'nt.. } ?> Link to comment https://forums.phpfreaks.com/topic/98592-exit-from-php/#findComment-504587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.