ripple - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of ripple.php

  1. <?php
  2. $text = <<<XML
  3. <ws_response>
  4.   <status>OK</status>
  5.   <resp_value>OK</resp_value>
  6.   <resp_detail>
  7.   <responseStatus>
  8.     <status>SUCCESS</status>
  9.     <requestId>RQT-397731730</requestId>
  10. </responseStatus></resp_detail>
  11. </ws_response>
  12.  
  13. XML;
  14.  
  15. $xml = simplexml_load_string($text);
  16.  
  17. // get the result with xpath (apparently always returns an array)
  18. $result = $xml->xpath('//resp_detail/responseStatus/status/text()');
  19.  
  20. var_dump($result);
  21. var_dump((string) $result);
  22. var_dump($result[0]);
  23.  
  24.  
  25. // get the string with simplexml's object syntax
  26. var_dump((string) $xml->resp_detail->responseStatus->status);
  27.  
  28. // i expected this to be an error
  29. var_dump((string) $xml->resp_detail->fakefake->status);
File Description
  • ripple
  • PHP Code
  • 28 Oct-2020
  • 692 Bytes
You can Share it: