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) ?

3 Answers 3

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'));
Sign up to request clarification or add additional context in comments.

1 Comment

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 !
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?

1 Comment

It wasn't this but thanks for the answer, I didn't know that a zero width space existed.
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.

1 Comment

You're totally right. A good idea that I should have had immediately :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.