php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据,会得到下面的错误 错误:Cannot use object of type stdClass as array 产生原因: +展开 -PHP $res = json_decode($res); $res['key']; //把 json_decode() 后的对象当作数组使用. 解决方法(2种):1.使用 json_decode($d, true).就是使json_decode 的第二个变量设置为 tru
一直对Function()一知半解,今日就Function()的使用做一下总结 一.函数实际是功能完整的对象,用Fucntion()直接创建函数. 语法规则: var 函数名 = new Function( arg1, arg2, arg3, ..., argN, body ); 解释: Function 构造函数所有的参数都是字符串类型的,body是生成函数的函数体. 实例:求多个参数的和 var fnSum = new Function( 'var total = 0,ar
function jsonDateFormat(jsonDate) {//json日期格式转换为正常格式 try { var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10)); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMont