mg_test - 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 mg_test.php

  1. <?php
  2. /**
  3. $result = '{
  4.   "route": {
  5.       "description": "Sample route",
  6.       "created_at": "Wed, 15 Feb 2012 13:03:31 GMT",
  7.       "actions": [
  8.           "forward(\"http://myhost.com/messages/\")",
  9.           "stop()"
  10.       ],
  11.       "priority": 0,
  12.       "expression": "match_recipient(\".*@samples.mailgun.org\")",
  13.       "id": "4f3bad2335335426750048c6"
  14.   }
  15. }';
  16.  
  17. $temp_result = json_decode($result, true);
  18.  
  19. $mg_route_id = $temp_result["route"]["id"];
  20.  
  21. echo $mg_route_id;
  22. */
  23.  
  24. $result = 'stdClassObject ( [http_response_body] => stdClass Object ( [message] => Route has been created [route] => stdClass Object ( [actions] => Array ( [0] => forward("[email protected]") [1] => stop() ) [created_at] => Sat, 17 Aug 2019 14:16:01 GMT [description] => test41 [expression] => match_recipient("[email protected]") [id] => 5d580c21fcd60027c2ea9053 [priority] => 0 ) ) [http_response_code] => 200 ) ';
  25.  
  26. $darr = json_encode($result);
  27. $data = json_decode($darr, true);
  28.  
  29. echo $data["http_response_body"]["id"];
  30.  
  31. /** echo $result->http_response_body->message; */
  32.  
  33. /** $mg_route_id = $result->route;
  34.  
  35. print_r($mg_route_id); */
  36.  
  37. /** $mg_route_id = $temp_result->route->id;
  38.  
  39. print $mg_route_id; */
File Description
  • mg_test
  • PHP Code
  • 17 Aug-2019
  • 1.15 Kb
You can Share it: