"Incompatible file format" PHP Fatal Error With Encoded Files

Follow

Applies to:
Zend Guard (Encoder)
Zend Loader (PHP Runtime)

Summary

When loading an encoded PHP file or application using Zend Loader extension, you might get the following error instead of normal output:

Fatal error: Incompatible file format: The encoded file has format major ID 4, whereas the Loader expects 5 in /path/to/script.php on line 0

Or without a file path:

PHP Fatal error: Incompatible file format: The encoded file has format major ID 7, whereas the Loader expects 6

The errors above may vary in text with different path to files and different major ID numbers.

Reference

See the following KB to match between PHP version and Zend Guard encoder ID.

PHP Versions and APIs

Solution 1

Once you identify the encoded PHP version from the article above, according to the Encoder ID, you can switch to, or change your PHP runtime version to match that PHP version.

Solution 2

If you must use a given PHP runtime version, you will then need a re-encoded version of the original PHP script or application matching your runtime PHP version. If you are not the software vendor, then ask for such a project release from the software maintainer / owner.

Important Note
There is no option to "decode" and re-encode for different PHP versions. Once Guard encodes an open source script, it will only work within the same PHP version and security limits, if applied while encoding (including licensing).

Comments