The simplest way to do this is with a byte array and bitwise operations:
byte[] data = new byte[] {
(byte) (((ushort) this.server_port) >> 8),
(byte) ((ushort) this.server_port)
};
string server_port = (string) data;
It's also worth noting that your PHP output actually depicts 25565
, not 25566
. As you can see here, 25566
is actually 63DE
in hex.