1

I met a strange problem yesterday, and wondered how it could be possible. I'm making a curl request with PHP on a "webservice" returning an XML document and I var_dump the result.

What I didn't understand is that it displayed me string(160) "" which I understand this way : the variable your dumping is a string of 160 characters and is this "". For me it's as if php told me "your variable is white (it's black)".

Do you know what could make it happen (I use php 5.2.6) ?

hakre
  • 193,403
  • 52
  • 435
  • 836
vbourdeix
  • 13
  • 2

3 Answers3

2

I'm guessing you have only produced XML, without character data, e.g.:

var_dump('<something/>');

Try instead:

var_dump(htmlentities('<something/>'));

or, better yet, if you know the character set:

var_dump(htmlentities('<something/>', ENT_NOQUOTES, 'UTF-8'));
Brett Zamir
  • 14,034
  • 6
  • 54
  • 77
  • I had forgotten to check "Notify me daily of any new answers" so I was a little long to answer but you were right. I didn't think of checking with firebug but the tags were interpreted, so all became clear when I used htmlentities. Thanks ! – vbourdeix Apr 27 '11 at 07:41
1

It could be zero-width characters like this one: Unicode Character 'ZERO WIDTH SPACE' (U+200B)

Try doing a hex dump of the string using the method described here: How can I get a hex dump of a string in PHP?

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0

Check the source (view source) of web-page, you might find the answer.

I have personally ran into similar situation quite a while back.

I-M-JM
  • 15,732
  • 26
  • 77
  • 103