[英]PHP alternative syntax for try-catch
PHP has an alternative syntax for control structures ( http://php.net/manual/en/control-structures.alternative-syntax.php ) and I've been used it very often lately until I got stuck looking for an alternative syntax for try-catch. PHP为控制结构提供了一种替代语法( http://php.net/manual/en/control-structures.alternative-syntax.php ),直到最近我一直在寻找替代语法之前,我都经常使用它试用。
Is there any alternative syntax for try-catch? try-catch是否有其他语法? If not, does anyone know why PHP doesn't include it as one of its feature, given it has alternative for other structures?
如果不是,有谁知道为什么PHP不将它作为其功能之一包含,因为它可以替代其他结构?
There is no such alternative syntax because IMHO try/catch instruction is not a control conditional structure like if, switch,... The catch block just handles exception. 没有这样的替代语法,因为IMHO try / catch指令不是控制条件结构,例如if,switch,... catch块仅处理异常。
From php documentation : 从PHP 文档 :
Code may be surrounded in a try block, to facilitate the catching of potential exceptions
代码可以放在try块中,以方便捕获潜在的异常
No, there isn't an alternative syntax for try-catch. 不,try-catch没有其他语法。 Why?
为什么? No one's asked for it.
没有人要求它。 You can take the first step and open an RFC .
您可以迈出第一步并打开RFC 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.