[PHP]Fix simplexml_load_string() parser error. (file_get_contents returning garbled data)

simplexml_load_string() get parser error and utf8_encode won't solve the problem.
I found out that file_get_contents is the key.

simplexml_load_string() not working because of parser error/


This is the error message.
Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in test.php on line XXX

Most of the stackoverflow answer are "use utf8_encode()", but that is no help.
Use var_dump() the data and it's looks like garbled data, but if I download the file directly, it seems no problem.

simplexml_load_string() is not the problem, file_get_contents just returned garbled data!


I end up find out that it's not display garbled because php can't detect file_get_contents returned date's encode.
file_get_contents returned date is just garbled.

Response data is being compressed!


if file_get_contents gets GZ compressed data(gzip/zlib), it's display garbled.
What you need is just put "compress.zlib://" before url.

file_get_contents('compress.zlib://http://example.com');