我有一个PHP类在做一些事情:
<?php
class Cart {
//....
}
$cart = new Cart();
$cart->init();
function deposit_total(){
global $cart;
$totals = array_sum( $cart::$deposits );
return $totals;
}
如何使用$cart
仅在函数中实例化(deposit_total()
) 课外活动?非常感谢。