Invalid characters at end of PHP Phar file print to screen on production server but not on local server

395 views Asked by At

I built a Drupal website with a custom module to integrate functionality from a company called MemberSuite. MemberSuite's PHP API is in a .phar file. I have little experience with .phar files, but everything works great on my local Ubuntu machine.

After I uploaded everything to a live server, I discovered strange characters at the top of every page. Traced the problem to the .phar file and found gibberish after the closing PHP tag:

enter image description here

This doesn't cause any issues on my local machine, but it outputs the following to the live server:

enter image description here

I think this has something to do with encoding, but I'm not an expert on the subject. I tried removing the characters from the end of the .phar file, but that results in a fatal error because of a hash/security check of the .phar file.

Is there a simple PHP configuration setting that would cause the .phar file to work on one server and not another?

1

There are 1 answers

0
cweiske On BEST ANSWER
  • It's not a BOM, that is only at the beginning of a file
  • Phar files are archive files, and there are markers within in that determine beginning and end of a file in the phar. You are seeing such a one
  • That it works on one server and not on another is usually some version conflict. Check your PHP version on the server, and on your local machine. The local one will probably be higher.
    • Downgrade your local PHP version and you'll probably be able to reproduce the error.
    • Compare the PHP versions with the recommended/minimum version of your membersuite api phar file.
  • Alternatively, extract the phar and use the files directly