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 .
精彩评论