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 在ISIS中什么是IP从地址
  • ¥15 压测时,并发量过高时,响应时间出现尖刺
  • ¥15 关于vmprotect3.8.4虚拟文件一项
  • ¥15 在不用IT调试的情况下怎样能连外网
  • ¥20 C#调用虚拟键盘TabTip.exe
  • ¥15 Qt4代码实现下面的界面
  • ¥15 CCS离散化传递函数与仿真不一致
  • ¥15 prism提示我reinstall prism 如何解决
  • ¥15 asp.core 权限控制怎么做,需要控制到每个方法
  • ¥20 while循环中OLED显示中断中的数据不正确