久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php通過反射修改Exception實例的message屬性

      php通過反射修改Exception實例的message屬性

      通過查看 Exception 類的源碼可以知道, $message 屬性使用 protect 修飾, 且沒有提供 setMessage 方法。

      對于 Exception 實例應(yīng)該怎么修改 message 呢?答案是: 反射!

      $exception = new Exception('haha'); $message = " - use reflection appended message"; $reflectionObject = new ReflectionObject($exception); $reflectionObjectProp = $reflectionObject->getProperty('message'); $reflectionObjectProp->setAccessible(true); $reflectionObjectProp->setValue($exception, $exception->getMessage() . $message); print_r($exception->getMessage()); haha - use reflection appended message

      通過以上代碼,能把 $exception 中的 $message 修改掉!反射無敵。。。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號