如何实例化和填充下面的stdClass对象?

stdClass Object ( [_] => 399.99 [currencyID] => USD )


这是完整的stdClass输出。

stdClass Object ( [Timestamp] => 2014-02-24T22:59:33Z [Ack] => Success [CorrelationID] => 693d0b129fdab [Version] => 71.0 [Build] => 9720069 [Balance] => stdClass Object ( [_] => 399.99 [currencyID] => USD ) [BalanceTimeStamp] => 2014-02-24T22:59:33Z [BalanceHoldings] => stdClass Object ( [_] => 399.99 [currencyID] => USD ) )


我的目标是为PayPal交易金额值的BasicAmountType组成stdClass。

最佳答案

一种实现方法是将数组强制转换为对象。

$obj = (object) array('_' => 399.99, 'currencyID' => 'USD');

关于php - 什么是组成以下标准对象的PHP代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22001249/

10-13 00:19