<?php $retry=0; while($retry++ <10){ try{ //正常代码 - 连接库 }catch(Exception $e){ sleep(1); continue; } break; }