第31篇熟悉老师与学生建房间与连接及php的date和include及require

来源:互联网 发布:拿破仑为什么称帝知乎 编辑:程序博客网 时间:2024/04/28 03:55

关键词:WebRTC-IOS一对一bug处理,熟悉老师与学生建房间与连接,phpdateincluderequire

一、WebRTC-IOS一对一bug处理

1.1老师端(chrome)开房间VS学生(IOS手机)进

二、修改代码(学生端建房间、老师端进入)

2.1 熟悉老师与学生建房间与连接

1)老师端:connection.onopen如下:

connection.onopen = function() {

   document.getElementById('input-text-chat').disabled = false;

   document.getElementById('start_anwser').style.display = "";

   document.getElementById('give_up').style.display = "";

   if (connection.getAllParticipants().join(', ') == connection.sessionid){          

        var start_anwserBtn =document.getElementById("start_anwser");

        start_anwserBtn.style.display ="none";

   }

   if (designer.pointsLength <= 0) {

        // make sure that remote user gets alldrawings synced.

        setTimeout(function() {

            connection.send('plz-sync-points');

        }, 1000);

   }

};

2)学生端:connection.onopen如下:

connection.onopen = function() {

   document.getElementById('input-text-chat').disabled = false;

   MyAlert("<p class='ready'>课堂已连接</p>", 1000, "","", "auto", "auto", 1);

   if (designer.pointsLength <= 0) {

        // make sure that remote user gets alldrawings synced.

        setTimeout(function() {

            connection.send('plz-sync-points');

        }, 1000);

   }

};

3)老师端用到roomid

var roomid = params.roomid;

if (roomid &&roomid.length) {

   connection.open(roomid, function() {

        showRoomURL(connection.sessionid);

   });

}

4) 这个函数用于获取网址中的房间号

(function() {

   var params = {},

        r = /([^&=]+)=?([^&]*)/g;

 

   function d(s) {

        returndecodeURIComponent(s.replace(/\+/g, ' '));

   }

   var match, search = window.location.search;

   while (match = r.exec(search.substring(1)))

        params[d(match[1])] = d(match[2]);

        window.params = params;

})();

三、PHP

3.1 date()

PHP date() 函数用于格式化时间/日期,可把时间戳格式化为可读性更好的日期和时间。时间戳是一个字符序列,表示一定的事件发生的日期/时间。

语法如下:

string date ( string $format [, int $timestamp ] )

看个例子:

注:就是说日期输出时的其中三个参数Y、m、d,中间加什么修饰的符号,比方说反斜杠、冒号之类的随便加。还有其它的参数,具体如下:

3.2 phpincluderequire语句

include 和 require 语句用于在执行流中插入写在其他文件中的有用的代码。

include 和 require 除了处理错误的方式不同之外,在其他方面都是相同的:

1)require 生成一个致命错误(E_COMPILE_ERROR),在错误发生后脚本会停止执行。

2)include 生成一个警告(E_WARNING),在错误发生后脚本会继续执行。

语法如下:

include 'filename';

或者

require 'filename';

看个include的例子:

注:没有header.php的话,将报一个警告,但还会继续往下执行。

看个require的例子:

注:找不到header.php,程序就停在那里,不再往下执行。

2016年12月14日星期三

1 0