语法兼容 5.2 问题

2016-10-13 16:28:22 +08:00
 uqf0663
<?php
class my_cls{
function __construct(){
$this->str=str_split('sfjhfsjfskdksdjkfskjsfkjsfkjfsfjvjhfjhv',1);
}
public function array_index($t){
return array_search($t, $this->str);
}
public function test($str){
for($i=0;$i<floor(strlen($str)/2);$i++){
$arr = array_map("my_cls::array_index",str_split(substr($str,$i*2,2)));
}
}
}




以上代码在 PHP5.4 是正常的,但是不兼容 5.2

请教一下 my_cls::array_index 应该怎么改才能兼容 PHP5.2 ?
2169 次点击
所在节点    PHP
6 条回复
jfcherng
2016-10-13 16:51:18 +08:00
可以試試 array($this, 'array_index')
uqf0663
2016-10-13 17:03:17 +08:00
@jfcherng 非常感谢,我自己琢磨了一下午,没想到解决起来这么简洁 ^_^
surfire91
2016-10-13 18:55:24 +08:00
uqf0663
2016-10-13 20:03:19 +08:00
@surfire91 感谢~
Outshine
2016-10-14 10:22:25 +08:00
为毛还要兼容 5.2 。。。
uqf0663
2016-10-14 12:13:36 +08:00
@Outshine 买的空间,该空间商只有 5.2 。。。。。。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/312543

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX