uqf0663
V2EX  ›  PHP

语法兼容 5.2 问题

  •  
  •   uqf0663 · Oct 13, 2016 · 3084 views
    This topic created in 3680 days ago, the information mentioned may be changed or developed.
    <?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 ?
    6 replies  •  2016-10-14 12:13:36 +08:00
    jfcherng
    jfcherng
    Oct 13, 2016❤️1
    1
    可以試試 array($this, 'array_index')
    uqf0663
    uqf0663
    OP
    Oct 13, 2016
    2
    @jfcherng 非常感谢,我自己琢磨了一下午,没想到解决起来这么简洁 ^_^
    surfire91
    surfire91
    Oct 13, 2016❤️1
    3
    uqf0663
    uqf0663
    OP
    Oct 13, 2016
    4
    @surfire91 感谢~
    Outshine
    Outshine
    Oct 14, 2016
    5
    为毛还要兼容 5.2 。。。
    uqf0663
    uqf0663
    OP
    Oct 14, 2016
    6
    @Outshine 买的空间,该空间商只有 5.2 。。。。。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1083 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:33 · PVG 02:33 · LAX 10:33 · JFK 13:33
    ♥ Do have faith in what you're doing.