bsmither Posted July 30, 2014 Share Posted July 30, 2014 There is a function (that cannot be changed) which has an include: <?php function a() { include 'file.php'; echo 'work'; } ?> ==file.php== <?php echo 'play'; ## Need to leave a() now! ?> The included file can be changed. I would like a way for file.php to cause PHP to return out of the function a(). A return; statement in file.php has PHP pick up execution with the statement following include. What is there in PHP that will allow returning out of a() at some point in file.php? Quote Link to comment https://forums.phpfreaks.com/topic/290191-exit-function-early/ Share on other sites More sharing options...
trq Posted July 30, 2014 Share Posted July 30, 2014 return will work as expected. <?php function a() { include 'file.php'; echo 'work'; } file.php <?php echo 'play'; return; echo 'this will not be reached'; Quote Link to comment https://forums.phpfreaks.com/topic/290191-exit-function-early/#findComment-1486464 Share on other sites More sharing options...
bsmither Posted July 30, 2014 Author Share Posted July 30, 2014 Sorry, I wasn't clear. I want a statement in file.php to exit out of a(). In other words, I do not want the last statement in a(), which is echo 'work';, to be executed at all. Quote Link to comment https://forums.phpfreaks.com/topic/290191-exit-function-early/#findComment-1486466 Share on other sites More sharing options...
trq Posted July 30, 2014 Share Posted July 30, 2014 Yeah, if you can't change that function, that isn't going to happen. Quote Link to comment https://forums.phpfreaks.com/topic/290191-exit-function-early/#findComment-1486468 Share on other sites More sharing options...
trq Posted July 30, 2014 Share Posted July 30, 2014 Actually, there is a library that might be able to help you, just can't think of the name of it off the top of my head. Give me a second. Quote Link to comment https://forums.phpfreaks.com/topic/290191-exit-function-early/#findComment-1486469 Share on other sites More sharing options...
trq Posted July 30, 2014 Share Posted July 30, 2014 I've not used this myself, just remember reading about it: http://go.aopphp.com Looks interesting yet scary. Quote Link to comment https://forums.phpfreaks.com/topic/290191-exit-function-early/#findComment-1486470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.