Php exit() function print message

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?

Upvotes: 0

Views: 1231

Answers (1)

PaulH
PaulH

Reputation: 3049

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']}";

Upvotes: 2

Related Questions