Migration to PHP 8
Having installed Debian 13, I am now running PHP 8.
Previous system upgrades gave me no problems and I could use my PHP source files without change. However, there was this one library (for conversion of coordinates) which I had been using for many years and which after migration to PHP 8 started mysteriously giving me division-by-zero errors and weird syntax errors.
I tried and followed the link to the original website I had downloaded it from, but the link was not working; perhaps the original author is not supporting it any more; so it seemed I was on my own.
Opening the file with vim, I saw a lot of ^M characters where lines were supposed to end; these were obviously to represent the non-printable U+000d character (hint: its decimal value is 13 and M is the 13th letter of the alphabet). Maybe the file was originally created on a Mac because it seemed it had these U+000d characters instead of the normal Unix U+000a newlines and not in addition to them (the syntax errors were suggesting as if some lines which were supposed to be interpreted were considered continuations of one-line comments).
This apparently had not been a problem for the previous versions of PHP interpreter but was now with PHP 8.
So, to replace the U+000d characters by proper Unix newlines, I executed the following command in VIM:
:s/^M/\r/g
however, where is says ^M, I inserted the actual U+000d character by pressing Ctrl-V u 0 0 0 d.
This resolved the syntax errors but not the divisions by zero! It seemed as if some class constructors, which were supposed to initialise objects with some values, were not working. But why??
After some googling, I found out that apparently PHP 8 does not support the constructors being named by the name of the class any more (which is the way familiar from C++).
So the next step to do was, inside of every class Something { class declaration, where it says function Something, I needed to replace it with function __construct (starting with two underscores).
With that, all the problems were fixed and everything is working now :)
Comments
No comments.