douyun4524 2014-10-09 17:26
浏览 38
已采纳

如何从OpenTok / PHP显示错误消息

I'm trying to use the OpenTok PHP SDK but can't seem to get it to work from the start. The code below will work and return the "Success" message. However, if I try to create a new OpenTok object by commenting that line, the message will no longer display.

Is there a way to get some error reporting on what's going on here or other things I should verify?

<?php

   require_once 'OpenTok/OpenTok.php';
   require_once 'OpenTok/Session.php';

   //$apiObj = new OpenTok("*******", "********");

   echo "Success";

?>
  • 写回答

1条回答 默认 最新

  • duanli9569 2014-10-09 18:19
    关注

    In general, you should first understand how PHP does exception handling

    In this case, one quick way to get an error message would be to wrap the code in a try/catch block

    try {
        require_once 'OpenTok/OpenTok.php';
        require_once 'OpenTok/Session.php';
    
        $apiObj = new OpenTok("*******", "********");
    
        echo "Success";
    } catch (Exception $e) {
        echo "Caught exception: ",  $e->getMessage(), "
    ";
    }
    

    More specifically, if you are using the latest OpenTok PHP SDK, the recommended way to load the classes is using a PSR-0 autoloader, such as the one generated by Composer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序