CaptainChainsaw Posted August 29, 2012 Share Posted August 29, 2012 Hi all, Would anyone be able to explain why I get a value in the variables "$redirecturl" and "$message" in the first example below but not in the second example? As soon as the condition to check for success has been evaluated the object disappears: if ($result->GetUnsecuredLenderResult->Success) { // object disapepars after this line Works in this example: try { $result = $client->GetUnsecuredLender( $params ); $continueurl = trim($result->GetUnsecuredLenderResult->ContinueUrl); $responsetext = trim($result->GetUnsecuredLenderResult->ResponseText); if ($result->GetUnsecuredLenderResult->Success) { $result = "A"; $redirecturl = $continueurl; $message = $responsetext; } else { // reject $result = "R"; $redirecturl = $continueurl; $message = $responsetext; } } catch (Exception $e) { // exception $result = "E"; $redirecturl = ""; $message = $e->getMessage(); } Doesn't work in this example: try { $result = $client->GetUnsecuredLender( $params ); if ($result->GetUnsecuredLenderResult->Success) { $result = "A"; $redirecturl = trim($result->GetUnsecuredLenderResult->ContinueUrl); $message = trim($result->GetUnsecuredLenderResult->ResponseText); } else { // reject $result = "R"; $redirecturl = trim($result->GetUnsecuredLenderResult->ContinueUrl); $message = trim($result->GetUnsecuredLenderResult->ResponseText); } } catch (Exception $e) { // exception $result = "E"; $redirecturl = ""; $message = $e->getMessage(); } Any advice on this would be appreciated as always. Cheers, CaptainChainsaw Quote Link to comment https://forums.phpfreaks.com/topic/267738-soap-response-object-disappears/ Share on other sites More sharing options...
ignace Posted August 29, 2012 Share Posted August 29, 2012 You overwrite the object: if ($result->GetUnsecuredLenderResult->Success) { // $result === object $result = "A"; // $result === string PHP is dynamic typed which means that it's type is defined by whatever you assign it. http://php.net/manual/en/language.types.type-juggling.php Quote Link to comment https://forums.phpfreaks.com/topic/267738-soap-response-object-disappears/#findComment-1373516 Share on other sites More sharing options...
CaptainChainsaw Posted August 29, 2012 Author Share Posted August 29, 2012 Ahhh yeah, that was glaringly obvious, couldn't see the wood for the trees. Thank you, makes perfect sense! Quote Link to comment https://forums.phpfreaks.com/topic/267738-soap-response-object-disappears/#findComment-1373518 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.