开发者

How to save simplexml node value to string?

I am trying to get a value in a node, and save it into a string variable. I ha开发者_运维问答ven't used PHP in about 5 years so I have no idea what is going on?

string $errorMessage = (string)$error->message);
print_r($errorMessage);

returns nothing


first do

$errorMessage = (string)$error->message;

and dont do print_r its used for echoing array simply use echo instead so

echo $errorMessage;

Php is not strongly typed language so you dont need to do string $errorMessage; , but still casting is pressent in php , coz objects such as simplexml implements __toString magic function which gets called automaticaly when you cast that object as string .

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜