$id = $this->input->post('program_id');
$related_change = json_decode($this->input->post('related_change'));
$data = array(
'user_key' => $related_change('user_key'),
'channel_id' => $related_change('channel_id'),
'date' => $related_change('date'),
'program' => array(
'name' => $related_change->('program_name'),
'type' => $related_change('program_type'),
'start_time' => date('Y-m-d H:i:s', $related_change('program_start_timestamp')),
'end_time' => date('Y-m-d H:i:s', $related_change('program_end_timestamp')),
'duration' => (int)$related_change('program_end_timestamp') - (int)$related_change('program_start_timestamp'),
'source_duration' => time_to_sec($related_change('program_original_duration')),
'source_type' => (string)$related_change('src_type'),
'source_start_ts' => $related_change('src_start_time')
'uri' => (string)$related_change('program_uri'),
)
);
这一块数据是解析的不对的
它们不是从 $thi->input->post 里面出来的, 而是从 $related_change 里面来的
该怎么写?
回复讨论(解决方案)
你打印 $this->input->post('related_change')这个出来看看啥就知道了。。。。
应该是传过来json串有问题
$related_change = json_decode($this->input->post('related_change'), true);$data = array( 'user_key' => $related_change['user_key'], 'channel_id' => $related_change['channel_id'], 'date' => $related_change['date'], 'program' => array( 'name' => $related_change['program_name'], 'type' => $related_change['program_type'], 'start_time' => date('Y-m-d H:i:s', $related_change['program_start_timestamp']), 'end_time' => date('Y-m-d H:i:s', $related_change['program_end_timestamp']), 'duration' => (int)$related_change['program_end_timestamp'] - (int)$related_change['program_start_timestamp'], 'source_duration' => time_to_sec($related_change['program_original_duration']), 'source_type' => (string)$related_change['src_type'], 'source_start_ts' => $related_change['src_start_time'], 'uri' => (string)$related_change['program_uri'], ));
json_decode() 第二个参数没设置成TRUE的时候是返回对象的,对象应该用 $related_change->user_key 来访问。或者就传入第二个参数为TRUE,以数组形式访问。像3楼那样写。

PHP和Python各有优势,选择应基于项目需求。1.PHP适合web开发,语法简单,执行效率高。2.Python适用于数据科学和机器学习,语法简洁,库丰富。

PHP不是在消亡,而是在不断适应和进化。1)PHP从1994年起经历多次版本迭代,适应新技术趋势。2)目前广泛应用于电子商务、内容管理系统等领域。3)PHP8引入JIT编译器等功能,提升性能和现代化。4)使用OPcache和遵循PSR-12标准可优化性能和代码质量。

PHP的未来将通过适应新技术趋势和引入创新特性来实现:1)适应云计算、容器化和微服务架构,支持Docker和Kubernetes;2)引入JIT编译器和枚举类型,提升性能和数据处理效率;3)持续优化性能和推广最佳实践。

在PHP中,trait适用于需要方法复用但不适合使用继承的情况。1)trait允许在类中复用方法,避免多重继承复杂性。2)使用trait时需注意方法冲突,可通过insteadof和as关键字解决。3)应避免过度使用trait,保持其单一职责,以优化性能和提高代码可维护性。

依赖注入容器(DIC)是一种管理和提供对象依赖关系的工具,用于PHP项目中。DIC的主要好处包括:1.解耦,使组件独立,代码易维护和测试;2.灵活性,易替换或修改依赖关系;3.可测试性,方便注入mock对象进行单元测试。

SplFixedArray在PHP中是一种固定大小的数组,适用于需要高性能和低内存使用量的场景。1)它在创建时需指定大小,避免动态调整带来的开销。2)基于C语言数组,直接操作内存,访问速度快。3)适合大规模数据处理和内存敏感环境,但需谨慎使用,因其大小固定。

PHP通过$\_FILES变量处理文件上传,确保安全性的方法包括:1.检查上传错误,2.验证文件类型和大小,3.防止文件覆盖,4.移动文件到永久存储位置。

JavaScript中处理空值可以使用NullCoalescingOperator(??)和NullCoalescingAssignmentOperator(??=)。1.??返回第一个非null或非undefined的操作数。2.??=将变量赋值为右操作数的值,但前提是该变量为null或undefined。这些操作符简化了代码逻辑,提高了可读性和性能。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

Dreamweaver Mac版
视觉化网页开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境