开发者

String is not empty but not appearing when using var_dump

Currently I am trying to return a publicly available XML resource, though when I use var_dump($resource) it returns string(4390) " ".

I am us开发者_C百科ing CURL to retrieve the resource, and it successfully returns other resources. There's clearly something there (as you can see there is 4390 characters!) but it is not returning successfully.

I have tried wrapping it in utf8_encode though this has made no difference.

I have also tried returning it using print_r and <pre> tags though this too returned nothing.

Any help here would be great!


To display non-displayable characters from strings, don't use var_dump but print out a hex-dump of the string, for example

echo bin2hex($resource);

using bin2hexDocs, but the link above has more alternatives to offer. Take what suits your debug needs best.

Edit: In case you're actually outputting HTML or XML elements, use htmlspecialcharsDocs:

echo htmlspecialchars($result);


What type of text is in the xml? If there are just html tags try to view the source code of the internet page. Maybe they wont be displayed because your browser interpret the html and dont show the tags


Or you can use Kint instead of var_dump to display the debug output. It will show the most information about the dumped variables in the most readable way. Needless to say it displays html effortlessly too.

Screenshot:

String is not empty but not appearing when using var_dump


(source: github.io)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜