dphdh395195 2016-02-01 08:20
浏览 464

如何从php页面调用变量到另一个?

I have the following codes:

$n = $totalMins/60;
    $whole = floor($n);
    $fraction = $n - $whole;

    $totalHrs += $whole;
    $totalMins = round($fraction*60);
    $total = "$totalHrs hours and $totalMins mins";
    $totalDeci = round($fraction, 2);

    $totalDeci += $totalHrs;
    $totalDeci = number_format($totalDeci, 2);

I want the $totalDeci to be called on another php page that I have. Is there a way for me to call it? I'm not really familiar with php.

  • 写回答

2条回答 默认 最新

  • douxie9471 2016-02-01 08:45
    关注

    Use session variables.

    Page1.php:
        <?php
        session_start();
        $_SESSION['your_variable'] = 'your_value';
        ?>
    
    Page2.php:
        <?php
        session_start();
        echo $_SESSION['your_variable'];
        ?>
    
    Page2.php will show: your_value
    

    Hope it will help you :)

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办