如果使用 PHP,则跳过父级
不确定这是否可能,但代码的基本思想如下:
if(isset($_POST['submit'])) {
if($_POST['field'] == 0) {
// do not process the code in the if statement
}
// code to process if the above validation criteria is not met
}
我基本上想尝试并使其尽可能简单,而不是到处都有大量的 if,只是顶部的快速验证语句,并且如果没有那些 if 语句被触发,它将处理代码以更新数据库等。
我尝试了 continue
语句函数,但没有任何喜悦,我相信它只适用于循环。
谢谢!
Not sure if this is even possible, but the basic idea of the code is as follows:
if(isset($_POST['submit'])) {
if($_POST['field'] == 0) {
// do not process the code in the if statement
}
// code to process if the above validation criteria is not met
}
I basically want to try and keep it as simple as possible without lots of if's everywhere, just the quick validation statements at the top, and if none of those if statements are triggered, it will process the code to update the database etc.
I have tried the continue
statement function with no joy, I believe that only works with loops.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为一个函数
As a function
您可以将所有这些放入一个函数中,然后从“if”内部调用“return”:
You could put all of this in a function and then call 'return' from the inside 'if':
要按照您最初的期望完成此操作,您需要使用
break
语句。 来自 PHP 手册:To accomplish this as you originally desired, you need to use the
break
statement. From the PHP manual: