简体   繁体   中英

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.

Is there any alternative syntax for 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?

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.

From php documentation :

Code may be surrounded in a try block, to facilitate the catching of potential exceptions

No, there isn't an alternative syntax for try-catch. Why? No one's asked for it. You can take the first step and open an RFC .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM