dsw1608 2014-12-11 13:48
浏览 10

如何在不同页面中使用计算值

I have made a shopping cart , but I am really struggling to get the the value of a calculation in a different page.

I have the following calculation in one page:

private function update_delivery() {


        if($this->subtotal > 329) {

                $this->delivery = 0;}

            if($this->subtotal < 329) { 
                $this->delivery = 7.99;
                }}

class Jcart {

    public $config     = array();
    private $items     = array();
    private $names     = array();
    private $prices    = array();
    private $qtys      = array();
    public $delivery      = 0;
    private $subtotal  = 0;
    private $itemCount = 0;


    function __construct() {

        // Get $config array
        include_once('config-loader.php');
        $this->config = $config;
    }

I want to use this->delivery value in a different page. This might be really easy, however I am really struggling, any help welcome, or point me in the right direction to look up how to do it will be great.

  • 写回答

1条回答 默认 最新

  • doujingao6210 2014-12-11 13:53
    关注

    You can try and store that value in a $_SESSION variable. This kind of variables exists in every page where you have session_start(). For instance: $_SESSION['delivery']=$this->delivery.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!