douwen5951 2019-02-19 19:19
浏览 90

将PHP 5.6代码转换为5.4 - 意外的'。'

i have prestashop module that is compatible only with PHP 5.6+, but my site is running PHP 5.4, so i am converting the code to PHP 5.4

I have this problem i cant figure out. Its: syntax error, unexpected '.', expecting ')'

public static $files = array (
    '15527491986d870fa01b8ac01c3aae85' => __DIR__ . '/../..' . '/src/GdprCustomScript.php',
);

I suppose the problem is the dot after DIR, should i change the dot for comma?

  • 写回答

2条回答 默认 最新

  • dongzhi6927 2019-02-19 19:26
    关注

    PHP 5.4 and 5.6 have both reached end-of-life. You should be migrating your code to PHP 7.1 or later, not to an older version.

    Regardless -- constant expressions were a new feature in PHP 5.6. There is no way to declare a static class variable using an expression in PHP 5.4.

    In theory, you could initialize the variable in code following the class, e.g.

    class Whatever {
        …
        public static $files;
        …
    }
    
    Whatever::$files = array( … );
    

    However, I'll reiterate that you need to migrate to a supported version of PHP. PHP 5.4 has been end-of-life since September 2015. If your web host does not support any newer versions, you need to find a better web host.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法