Php exit()函数打印消息

时间:2016-07-05 07:04:55

标签: php

你可以帮帮我吗?我有这条线:

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

我需要打印:$orderRequest

我这样做:

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

也许有更简单的方法可以做到这一点?

1 个答案:

答案 0 :(得分:2)

这是一种简化方法:

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

此外,仅当您在{$currency}

中使用双引号字符串打印数组键时,才需要echo "{$currency['key']}";之类的大括号