PHP:是否可以从 php 类/对象内部结束像 exit() 这样的脚本
可以这样做吗?
$objetc -> runAndFinish();
echo "this should not be echoed";
而不是这个?
$objetc -> runAndFinish();
exit();
echo "this should not be echoed";
所以 runAndFinish();方法会以某种方式结束脚本处理。 是否可以?
Is it possible to do this?
$objetc -> runAndFinish();
echo "this should not be echoed";
instead of this?
$objetc -> runAndFinish();
exit();
echo "this should not be echoed";
So runAndFinish(); method would somehow end the script processing.
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
放置一个 exit();在你的类中 runAndFinish();方法
Put an exit(); inside of your classes runAndFinish(); method
将退出调用放在方法中,它将在调用过程中退出
Put the exit call in the method and it will exit during its call
如果您在课堂上,您可以使用:
If you are in a class you can use:
是的,当然有可能。如果您将
exit()
或die()
(或其他可能结束执行的内容)放入该特定方法中,它将执行。据我所知,与其他任何方法相比,您可以在方法中执行的内容没有任何特殊限制。
Yes, of course it's possible. It you put
exit()
ordie()
(or something else that might end execution) in that particular method and it will execute.To my knowledge, there aren't any special restrictions for what you can execute in a methods vs. anything else.