0
votes

Trying to debug a composer error that's happening on my windows machine and not my linux server. Here's the code I'm trying to execute

$url = "https://packages.zendframework.com/packages.json";
var_dump(file_get_contents($url));

When I execute this, I get something like: http://grab.by/pSFI

As you can tell, the weird utf8 character at the beginning should not be there. It does not happen with non-secure protocol (but this url with 301 to secure anyways, so it's not possible to demonstrate).

Any ideas? Is it an openssl dll issue?

2
Nothing weird shown to me!undone
What does file() return?Glavić
file() return screenshot: grab.by/pSWqsb8244
@undone, There is an extraneous character at the front which messes up the script that depends on this workingsb8244

2 Answers

1
votes

This was a windows setup issue that was solved by using xamp instead of wamp. There is a bug in the php build used by my wamp instance that would mess up file_get_contents on ssl destinations. It is working correctly after switching to xamp.

0
votes

These steps would usually do the trick as they are the only reasons I can think of offhand where I've seen that character.

  1. Open your file.
  2. Make sure it has UNIX line endings.
  3. Trim the white space on save.
  4. Make sure there is nothing before the first character. ( Hit backspace for fun before first character, if you don't see anything, in case a control character somehow got copy pasted in that you can't see )
  5. Make sure your server is returning UTF-8 encoded headers

Also, do not develop in different environments... all of them should match. There can be plenty of quirks that are different between different systems. I even had memcache issues on one environment, but not the other, before we got all environments synced. Even worse, you might not see a bug on your dev environment that pops up in production... and then you won't be able to debug it.