0

can you help me? I have this line:

$orderRequest = new CreateOrderRequest(null, "BTC", null, $currency, $amount, $orderDescription, "en", $callbackUrl, $successUrl, $cancelUrl);

I need to print: $orderRequest

I do it like this:

exit("orderRequest: {$currency} {$amount}; {$orderDescription}; {$callbackUrl}; {$successUrl}; {$cancelUrl}");

Maybe there is an easier way to do this?

4
  • 1
    for that use only print_r($orderRequest) Commented Jul 5, 2016 at 7:07
  • That depends on what you are trying to achieve. from my perspective, this looks fine. but it's hard to tell if this is the optimal way of doing what you are trying to do, since we can't see the rest of your code, and don't know what is happening besides that exit statement Commented Jul 5, 2016 at 7:07
  • This looks wrong to me, you are not actually printing $orderRequest, just the variables you sent to its constructor. Apart from that, you might want to send something back that the receiving end can do something with, like html or json. Commented Jul 5, 2016 at 7:14
  • @KarolisTamašauskas Please mark one of the answers as accepted or comment so that people don't come here thinking you still need help. Commented Jul 5, 2016 at 11:48

1 Answer 1

2

Here's a way to simplify:

echo '<pre>'; // easy way to improve print_r layout (newlines)
print_r($orderRequest); // can print objects and arrays, while exit() doesn't
exit(); // optional, depending if you want to terminate program execution

Also, the curly braces like for {$currency} are only needed when your print an array key in a double quoted string like in echo "{$currency['key']}";

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.