← Back to context

Comment by 0x073

10 hours ago

I have some apps that works from 5.3 to 8.5. php has great compatibility, if you don't rely on external libraries or framework and don't use types.

For PHP 8.5 code to work with PHP 5.3 you'd have to forego short array syntax, finally blocks, scalar type hints and nullable types (OK, you mention this), the ?? operator, the ?-> operator, traits, and probably a million other things that we use every day.

For PHP 5.3 code to work on PHP 8+ you'd have had to completely forego error catching because that was completely upended in 7.0 or 7.2 (I forget which), not used short open tags, never used the class name as a constructor (that happened a lot in PHP 5), have no mcrypt functions, not used __autoload(), have had the foresight to use PDO instead of mysql_ (was PDO available in 5.3? I'd never seen it that early I think), you'd have had to be fortunate enough to not used ereg_, I think that older versions used # in ini file comments (I remember that breaking at some point, don't remember when), never used each(), not used safe_mode for mysql (strange because that was the default I think), and probably a million other issues that I hadn't encountered. If you have codebase written for PHP 5.3 that still works on modern PHP, I'd love to see it. I honestly don't believe such a codebase exists beyond the most trivial.

  • Most of the apps where developed for php 5.2-5.3 , as many things that you wrote where already bad code in this time. Spl autoloader, MySQLi, __construct was already available.

    The apps are internal legacy apps so I can't share the codebase.

    Because of this there was no big rewrite like types etc.