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

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

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来