SLIM框架停止调用 [英] SLIM framework Halt call

查看:134
本文介绍了SLIM框架停止调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对Slim Framework php有疑问.

Have a question on Slim Framework php.

在我的应用程序中,如果条件不匹配,我想停止应用程序的执行.

In my application, I would like to stop the application execution if a condition is mismatched.

根据Slim文档,有暂停功能.但这似乎不起作用. 甚至在调用Halt之后,应用程序仍继续执行.

There is a halt function, per Slim documentation. But that does not appear to be working. the application continuous to execute even after calling Halt.

伪代码:

if ( $valid ) {
         // Do something
} else {
    $app->halt(500, "not valid");
}
// Other code here.


$app->run();

我期望我们调用Halt函数,其他代码"不应执行. 但事实并非如此.

I was expecting that, we we call Halt function, the "Other code" should not execute. But it does not appear to be the case.

有什么想法吗?

推荐答案

您始终可以调用手动exit 停止脚本执行.

You can always call exit manually to stop the script execution.

$app->halt(500, "not valid");
exit;

这篇关于SLIM框架停止调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆