dqpdb82600 2012-06-27 12:47
浏览 45
已采纳

PHP 5.3 - 5.4垫片

My server is running PHP 5.2. Is there a collection of shims so I can use a least some new ability of PHP 5.3 in PHP 5.2? like:

<?php if ( !defined('__DIR__') ) define('__DIR__', dirname(__FILE__)); ?>

  • 写回答

1条回答 默认 最新

  • dougu1990 2014-07-22 12:22
    关注

    I can't recall all the features 5.3 and 5.4 brought to the table but the short answer is: no.

    5.3: Feature you mentioned (__DIR__ constant) is impossible to replicate unless you want to start every file with mentioned declaration (remember every file has different location).

    5.3: Closures can be simulated using create_function() but context passing with use() or any new syntax won't be accessible.

    5.4: Traits can be simulated using external configs and __call() handlers, but you'll need to write or inherit them in every class.

    5.4: Short array syntax is, well, impossible.

    The list goes on (binary notation, array item dereferencing, etc.) but answer is still - no.

    As for one example where it worked, there is a "polyfill" for PHP 5.5's array_column() function, you can find it below. It's too long to include in answer, so please don't vote it as link-only.

    http://benramsey.com/blog/2013/07/the-array-column-php-userland-library/ https://github.com/ramsey/array_column

    Look also at the project which emulates all functions brought up in PHP 5.1 and up: https://github.com/Polycademy/upgradephp

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 脱敏项目合作,ner需求合作
  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴