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 基于作物生长模型下,有限水资源的最大化粮食产量的资源优化模型建立
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo
  • ¥15 科来模拟ARP欺骗困惑求解
  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式