php try … else

后端 未结 6 1509
余生分开走
余生分开走 2021-01-07 18:50

Is there something similar in PHP to the try ... else in Python?

I need to know if the try block executed correctly as when the block executed correctly

6条回答
  •  隐瞒了意图╮
    2021-01-07 19:35

    PHP does not have try/catch/else. You could however set a variable in the catch block that can be used to determine if it was run:

    $caught = false;
    
    try {
        // something
    } catch (Exception $e) {
        $caught = true;
    }
    
    if (!$caught) {
    
    }
    

提交回复
热议问题