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.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog